Results 1 to 3 of 3

Thread: Configuring RequestMappingHandlerMapping when using mvc:annotation-driven

  1. #1
    Join Date
    Dec 2011
    Posts
    5

    Default Configuring RequestMappingHandlerMapping when using mvc:annotation-driven

    Hello,
    What happened to #spring? Anyway...

    Is there a sensible way to set RequestMappingHandlerMapping.useSuffixPatternMatch to false when I using <mvc:annotation-driven> in the XML config?

    This is for Spring 3.1 by the way.

    Cheers,
    M

  2. #2
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    The MVC Java config in Spring 3.1 provides the same benefits the the MVC namespace but also makes it easier to customize properties on the underlying beans:

    Code:
    @Configuration
    public class WebConfig extends WebMvcConfigurationSupport {
    
      @Override
      @Bean
      public RequestMappingHandlerMapping requestMappingHandlerMapping() {
        RequestMappingHandlerMapping hm = super.requestMappingHandlerMapping();
        hm.setSuffixPatternMatch(false);
        return hm;
      }
    
    }
    See the Javadoc on @EnableWebMvc or the reference documentation for more details.

  3. #3
    Join Date
    Feb 2010
    Posts
    21

    Default Works as expected

    I tried this approach with the application that is configured using XML and I removed annotation-driven from it and added @EnableWebMvc annotated configuration class and this works fine.

    Is this good approach to mix XML and JAVA configurations? Some of the mvc configuration (interceptors, view resolvers) are in XML, some in JAVA config.

    What's your opinion?

Posting Permissions

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