Announcement Announcement Module
No announcement yet.
@RequestMapping custom properties Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @RequestMapping custom properties

    As an example, take subdomain mapping.

    This article:
    recommends to resolve subdomain on Filter.

    If we'd like to create custom @RequestMapping property, such as subdomain, eg. to create mapping like this:

    @RequestMapping(value = "/some/action", subdomain = "www")
    public String handlerFunction(){
        return "view/id";
    We would have to override @RequestMapping @interface definition and override RequestMappingHandlerMapping protected methods, with our own implementation (

    Is this the way we should walk?

  • #2
    No you don't. The JIRA issue you refer to is related to the DefaultAnnotationHandlerMapping NOT the RequestMappingHandlerMapping. For this you can implement your own RequestCondition implementation(s) to do the mapping. However that would be more complex then the filter solution from the blog you mention.

    You could also use some URL rewriting to add it to the list of parameters (as another solution).


    • #3
      Oh, so it's my fault. I though that it's related to RequestMappingHandlerMapping from this comment:
      Type and method-level, custom request conditions can now be provided by overriding protected methods in RequestMappingHandlerMapping.
      The URL rewriting solution seems to be good solution, as I already use UrlRewriteFilter ( )

      But implementation of custom RequestCondition is the best ! I've honestly never heard about this one, and it perfectly conforms to my idea. Thanks Marten, you've probably saved me


      • #4
        And one more thing, I was digging a little bit, and found this project, as an example of RequestCondition implementation.

        Is it necessary to create own implementation of RequestMappingHandlerMapping as they do there, or can I register my own Method/Type RequestCondition through XML ?