| java.lang.Object | ||||||
| ↳ | org.springframework.context.support.ApplicationObjectSupport | |||||
| ↳ | org.springframework.web.context.support.WebApplicationObjectSupport | |||||
| ↳ | org.springframework.web.servlet.handler.AbstractHandlerMapping | |||||
| ↳ | org.springframework.web.servlet.handler.AbstractUrlHandlerMapping | |||||
| ↳ | org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping | |||||
| ↳ | org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping | |||||
Implementation of the HandlerMapping
interface that maps handlers based on HTTP paths expressed through the
RequestMapping annotation at the type or method level.
Registered by default in 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 Controller stereotype
at the type level. This is not strictly necessary when RequestMapping is
applied at the type level (since such a handler usually implements the
Controller interface). However,
Controller is required for detecting RequestMapping annotations
at the method level if 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 AnnotationMethodHandlerAdapter is responsible for processing
annotated handler methods, as mapped by this HandlerMapping. For
RequestMapping at the type level, specific HandlerAdapters such as
SimpleControllerHandlerAdapter apply.
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.core.Ordered
| |||||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From interface
org.springframework.web.servlet.HandlerMapping
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Set whether to register paths using the default suffix pattern as well:
i.e.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Add URLs and/or URL patterns for the given path.
| |||||||||||
Checks for presence of the
RequestMapping
annotation on the handler class and on any of its methods. | |||||||||||
Derive URL mappings from the handler's method-level mappings.
| |||||||||||
Derive URL mappings from the handler's method-level mappings.
| |||||||||||
Indicates whether this handler mapping support type-level mappings.
| |||||||||||
Validate the given annotated handler against the current request.
| |||||||||||
Validate the given type-level mapping metadata against the current request,
checking HTTP request method and parameter conditions.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
| |||||||||||
From class
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
| |||||||||||
From class
org.springframework.web.servlet.handler.AbstractHandlerMapping
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.core.Ordered
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.HandlerMapping
| |||||||||||
Set whether to register paths using the default suffix pattern as well: i.e. whether "/users" should be registered as "/users.*" and "/users/" too.
Default is "true". Turn this convention off if you intend to interpret
your @RequestMapping paths strictly.
Note that paths which include a ".xxx" suffix or end with "/" already will not be transformed using the default suffix pattern in any case.
Add URLs and/or URL patterns for the given path.
| urls | the Set of URLs for the current bean |
|---|---|
| path | the currently introspected path |
Checks for presence of the RequestMapping
annotation on the handler class and on any of its methods.
| beanName | the name of the candidate bean |
|---|
null or an empty array if none
Derive URL mappings from the handler's method-level mappings.
| handlerType | the handler type to introspect |
|---|
Derive URL mappings from the handler's method-level mappings.
| handlerType | the handler type to introspect |
|---|---|
| hasTypeLevelMapping | whether the method-level mappings are nested within a type-level mapping |
Indicates whether this handler mapping support type-level mappings. Default to false.
Validate the given annotated handler against the current request.
| handler | the handler object to validate |
|---|---|
| request | current HTTP request |
| Exception |
|---|
Validate the given type-level mapping metadata against the current request, checking HTTP request method and parameter conditions.
| mapping | the mapping metadata to validate |
|---|---|
| request | current HTTP request |
| Exception | if validation failed |
|---|