Spring MVC 3 : Ambiguous mapping found

后端 未结 2 1032
误落风尘
误落风尘 2021-02-13 03:35

I am playing with spring MVC 3.1 and testing different features. I wanted to verify following statement taken from @RequestMapping#value doc

If you have a single         


        
2条回答
  •  醉梦人生
    2021-02-13 04:06

    Arun, your answer is correct with the caveat that in Spring 3.1 it depends which HandlerMapping-HandlerAdapter pair is configured.

    The described behavior is supported with the DefaultAnnotationHandlerMapping & AnnotationMethodHandlerAdapter which have been in use since Spring 2.5 and are still enabled by default when no other HandlerMapping and HandlerAdapter beans are defined.

    The RequestMappingHandlerMapping and RequestMappingHandlerAdapter added in Spring 3.1 (see Spring 3.1 reference docs) as a replacement for the former do not support the same behavior -- i.e. falling back on the method name in case of ambiguous mappings as well as having a default method (when no explicit mappings are defined). The new HandlerMapping-HandlerAdapter pair is enabled by default from the MVC namespace and from MVC Java config and is recommended for use going forward.

    The Java doc referenced by Arun needs an update. I've created a ticket for that SPR-9042.

提交回复
热议问题