Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6524

Doc: <mvc:annotation-driven> incompatible to override strategy of handler mappings


    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 RC2, 3.0 RC3
    • Fix Version/s: 3.0 GA
    • Component/s: [Documentation], Web
    • Labels:


      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:

      1) declare in a web application context (e.g. using Spring's DispatcherServlet):


      <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"/>

      2) declare a java controller using @Controller
      3) start container with logging enabled and check logs for duplicate registration of the controller


          Issue Links



              • Assignee:
                kdonald Keith Donald
                rauar Alex Rau
                Last updater:
                Trevor Marshall
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created:
                  Days since last comment:
                  6 years, 49 weeks, 6 days ago