SpringMVC 3.0 to 3.1 Migration ControllerClassNameHandlerMapping

I have an existing application in Sping 3.0 that uses ControllerClassNameHandlerMapping to map the controller and methods, such as:

StartController.class is mapped to http://127.0.0.1/app/start/* 

then

 StartController.class has a method called init() that is mapped to http://127.0.0.1/app/start/init.html 

Here is my configuration:

 @Bean public ControllerClassNameHandlerMapping classNameControllerMappings() { return new ControllerClassNameHandlerMapping() {{ setCaseSensitive(true); setDefaultHandler(new UrlFilenameViewController()); setInterceptors(new Object[] {callProgressionInterceptorHandler(), callSessionInterceptorHandler(), localeChangeInterceptor()}); }}; } 

Most of my controllers have 5-15 query matching methods in each controller.

But when I upgrade to Spring 3.1+, the query mapping becomes ambiguous for each controller and is not displayed correctly.

I read that one solution is to explicitly add the name mthod:

 @RequestMapping(method = RequestMethod.GET) 

Now will be:

 @RequestMapping(method = RequestMethod.GET, value = "init") 

I really don't want to manually add the @RequestMapping value to 100+ methods if I don't need to.

Can someone help with a better solution?

Here is the error I get:

  47672 [btpool0-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'addressConfirmationController' bean method public void com.comcast.ivr.d2.web.controllers.AddressConfirmationController.houseNumber_rc(org.springframework.ui.ModelMap) to {[],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'addressConfirmationController' bean method 

I also added setOrder (1); to ControllerClassNameHandlerMapping and still get this error.

UPDATE: I saw the following snippet http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html :

Prior to Spring 3.1, type and type query type mappings were considered in two separate steps: first, the controller was selected by the DefaultAnnotationHandlerMapping method, and the actual call method was narrowed down by the second using the AnnotationMethodHandlerAdapter adapter.

With the new support classes in Spring 3.1, RequestMappingHandlerMapping is the only place to decide which method should process the request. Think of controller methods as a set of unique endpoints with mappings for each method derived from information about the type and level of the @RequestMapping method.

Does this mean that I cannot save the same @RequestMapping without adding the matching data to @RequestMapping, as I did <3.1?

I have hundreds of methods that will need to be changed for this to happen ...: - (

+4
source share

All Articles