Description
Alex Rau opened SPR-6524 and commented
the mvc:annotation-driven feature breaks or at least does not conform to the implemented strategy in MVC that there is an implicit DefaultAnnotationHandlerMapping (D1) which can be replaced with custom parameterized versions (D2) of handler mappings.
As soon as someone wants to use the above short-cut "mvc:annotation-driven" there will be a DefaultAnnotationHandlerMapping (D3) which a) cannot be replaced with a custom version (D2) anymore and b) replaces the implicit one (D1). Even worse - developers declaring (D3) assuming they would override the implicit one (D1) will end up with two instances of DefaultAnnotationHandlerMapping (D2 and D3) resulting in duplicate registration of annotated controllers (component scan) and custom parameterization which will be without any effect as D2 seems to win over D3.
I think at least a dedicated property for the above declaration should be defined which allows passing in a custom DefaultAnnotationHandlerMapping along with the declaration (+ some clarifying documentation about this wouldn't be too bad).
Steps to reproduce:
-
declare in a web application context (e.g. using Spring's DispatcherServlet):
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<context:component-scan base-package="org.retroduction" use-default-filters="false">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan> -
declare a java controller using
@Controller
-
start container with logging enabled and check logs for duplicate registration of the controller
Affects: 3.0 RC2, 3.0 RC3
Reference URL: http://forum.springsource.org/showthread.php?p=272494
Issue Links:
- Document new mvc namespace [SPR-6404] #11070 Document new mvc namespace ("is superseded by")