This class can be implemented by application developers, although this is not
necessary, as org.
and org.
are included in the framework. The former is the default if no
HandlerMapping bean is registered in the application context.
HandlerMapping implementations can support mapped interceptors but do not
have to. A handler will always be wrapped in a HandlerExecutionChain
instance, optionally accompanied by some HandlerInterceptor instances.
The DispatcherServlet will first call each HandlerInterceptor's
preHandle method in the given order, finally invoking the handler
itself if all preHandle methods have returned true.
The ability to parameterize this mapping is a powerful and unusual capability of this MVC framework. For example, it is possible to write a custom mapping based on session state, cookie state or many other variables. No other MVC framework seems to be equally flexible.
Note
Implementations can implement the org.
interface to be able to specify a sorting order and thus a priority for getting
applied by DispatcherServlet. Non-Ordered instances get treated as the lowest priority.
org.springframework.core.Ordered , org.springframework.web.servlet.handler.AbstractHandlerMapping , org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping , org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
| Modifier and Type | Field and Description |
|---|---|
| public static final String | BEST_MATCHING_HANDLER_ATTRIBUTE
Name of the |
| public static final String | BEST_MATCHING_PATTERN_ATTRIBUTE
Name of the |
| public static final String | INTROSPECT_TYPE_LEVEL_MAPPING
Name of the boolean |
| public static final String | LOOKUP_PATH
Deprecated
as of 5.3 in favor of
Name of the org. and
org..
HttpServletRequest attribute that contains the path
used to look up the matching handler, which depending on the configured
org. could be the full path
or without the context path, decoded or not, etc.
|
| public static final String | MATRIX_VARIABLES_ATTRIBUTE
Name of the |
| public static final String | PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
Name of the |
| public static final String | PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE
Name of the |
| public static final String | URI_TEMPLATE_VARIABLES_ATTRIBUTE
Name of the |
| Modifier and Type | Method and Description |
|---|---|
| public HandlerExecutionChain | Returns: a HandlerExecutionChain instance containing handler object and any interceptors, ornull if no mapping foundcurrent HTTP request request)Return a handler and any interceptors for this request. |
| public default boolean | usesPathPatterns()
Whether this |
| BEST_MATCHING_HANDLER_ATTRIBUTE | back to summary |
|---|---|
| public static final String BEST_MATCHING_HANDLER_ATTRIBUTE Name of the
| |
| BEST_MATCHING_PATTERN_ATTRIBUTE | back to summary |
|---|---|
| public static final String BEST_MATCHING_PATTERN_ATTRIBUTE Name of the Note This attribute is not required to be supported by all HandlerMapping implementations. URL-based HandlerMappings will typically support it, but handlers should not necessarily expect this request attribute to be present in all scenarios. | |
| INTROSPECT_TYPE_LEVEL_MAPPING | back to summary |
|---|---|
| public static final String INTROSPECT_TYPE_LEVEL_MAPPING Name of the boolean Note This attribute is not required to be supported by all HandlerMapping implementations. | |
| LOOKUP_PATH | back to summary |
|---|---|
| public static final String LOOKUP_PATH
Deprecated as of 5.3 in favor of
Name of the
| |
| MATRIX_VARIABLES_ATTRIBUTE | back to summary |
|---|---|
| public static final String MATRIX_VARIABLES_ATTRIBUTE Name of the Note This attribute is not required to be supported by all HandlerMapping implementations and may also not be present depending on whether the HandlerMapping is configured to keep matrix variable content | |
| PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE | back to summary |
|---|---|
| public static final String PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE Name of the Note This attribute is not required to be supported by all HandlerMapping implementations. URL-based HandlerMappings will typically support it, but handlers should not necessarily expect this request attribute to be present in all scenarios. | |
| PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE | back to summary |
|---|---|
| public static final String PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE Name of the Note This attribute is not required to be supported by all HandlerMapping implementations. Handlers should not necessarily expect this request attribute to be present in all scenarios. | |
| URI_TEMPLATE_VARIABLES_ATTRIBUTE | back to summary |
|---|---|
| public static final String URI_TEMPLATE_VARIABLES_ATTRIBUTE Name of the Note This attribute is not required to be supported by all HandlerMapping implementations. URL-based HandlerMappings will typically support it, but handlers should not necessarily expect this request attribute to be present in all scenarios. | |
| getHandler | back to summary |
|---|---|
| public HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception Return a handler and any interceptors for this request. The choice may be made on request URL, session state, or any factor the implementing class chooses. The returned HandlerExecutionChain contains a handler Object, rather than even a tag interface, so that handlers are not constrained in any way. For example, a HandlerAdapter could be written to allow another framework's handler objects to be used. Returns
| |
| usesPathPatterns | back to summary |
|---|---|
| public default boolean usesPathPatterns() Whether this
| |