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

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

    Details

    • 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:
      None

      Description

      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):

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

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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