Registered by default in {@link org.springframework.web.servlet.DispatcherServlet}on Java 5+. NOTE: If you define custom HandlerMapping beans in your DispatcherServlet context, you need to add a DefaultAnnotationHandlerMapping bean explicitly, since custom HandlerMapping beans replace the default mapping strategies. Defining a DefaultAnnotationHandlerMapping also allows for registering custom interceptors:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> ... </property> </bean>Annotated controllers are usually marked with the {@link Controller} stereotypeat the type level. This is not strictly necessary when {@link RequestMapping} isapplied at the type level (since such a handler usually implements the {@link org.springframework.web.servlet.mvc.Controller} interface). However,{@link Controller} is required for detecting {@link RequestMapping} annotationsat the method level if {@link RequestMapping} is not present at the type level.
NOTE: Method-level mappings are only allowed to narrow the mapping expressed at the class level (if any). HTTP paths need to uniquely map onto specific handler beans, with any given HTTP path only allowed to be mapped onto one specific handler bean (not spread across multiple handler beans). It is strongly recommended to co-locate related handler methods into the same bean.
The {@link AnnotationMethodHandlerAdapter} is responsible for processingannotated handler methods, as mapped by this HandlerMapping. For {@link RequestMapping} at the type level, specific HandlerAdapters such as{@link org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter} apply. @author Juergen Hoeller @author Arjen Poutsma @since 2.5 @see RequestMapping @see AnnotationMethodHandlerAdapter @deprecated in Spring 3.2 in favor of{@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping RequestMappingHandlerMapping}
|
|