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

  • @RequestMapping custom properties

    As an example, take subdomain mapping.

    This article: http://techsravi.blogspot.com/2011/0...ub-domain.html
    recommends to resolve subdomain on Filter.

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

    Code:
    @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 (
    https://jira.springsource.org/browse/SPR-7812).

    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).

    Comment


    • #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 ( http://www.tuckey.org/urlrewrite/ )

      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

      Comment


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

        https://github.com/rstoyanchev/spring-mvc-31-demo/

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

        Comment

        Working...
        X