Skip to content

Doc: <mvc:annotation-driven> incompatible to override strategy of handler mappings [SPR-6524] #11190

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

  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


Affects: 3.0 RC2, 3.0 RC3

Reference URL: http://forum.springsource.org/showthread.php?p=272494

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions