Results 1 to 4 of 4

Thread: @RequestMapping custom properties

  1. #1
    Join Date
    Apr 2012
    Posts
    15

    Question @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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2012
    Posts
    15

    Default

    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

  4. #4
    Join Date
    Apr 2012
    Posts
    15

    Default

    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 ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •