org.springframework.web.servlet.HandlerMapping
implementations. Supports ordering, a default handler, and handler interceptors,
including handler interceptors mapped by path patterns.Note
This base class does not support exposure of the
PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE. Support for this attribute
is up to concrete subclasses, typically based on request URL mappings.
getHandlerInternal, setDefaultHandler, setInterceptors, org.springframework.web.servlet.HandlerInterceptor
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private String | |
| private CorsConfigurationSource | |
| private CorsProcessor | |
| private Object | |
| private final List | |
| protected final Log | mappingsLogger
Dedicated "hidden" logger for request mappings. |
| private int | |
| private PathMatcher | |
| private PathPatternParser | |
| pack-priv static final String | |
| private UrlPathHelper |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected HandlerInterceptor | Returns: the interceptor downcast or adapted to HandlerInterceptorthe interceptor interceptor)Adapt the given interceptor object to |
| protected void | detectMappedInterceptors(List<HandlerInterceptor>
an empty list to add to mappedInterceptors)Detect beans of type |
| protected void | extendInterceptors(List<Object>
the configured interceptor List (never interceptors)null), allowing
to add further interceptors before as well as after the existing interceptorsExtension hook that subclasses can override to register additional interceptors,
given the configured interceptors (see |
| protected String | |
| public final HandlerInterceptor[] | Returns: the array of configured interceptors, ornull if none
are configured; this method also returns null if called too early,
or more specifically before
org..Return all configured interceptors adapted to |
| protected CorsConfiguration | Returns: the CORS configuration for the handler, ornull if nonethe handler to check (never handler, HttpServletRequest null).the current request. request)Retrieve the CORS configuration for the given handler. |
| public CorsConfigurationSource | |
| protected HandlerExecutionChain | getCorsHandlerExecutionChain(HttpServletRequest
the current request request, HandlerExecutionChain the chain to update chain, CorsConfiguration the CORS configuration applicable to the handler config)Update |
| public CorsProcessor | |
| public Object | |
| public final HandlerExecutionChain | Returns: the corresponding handler instance, or the default handlercurrent HTTP request request)Implements org. Look up a handler for the given request, falling back to the default handler if no specific one is found. |
| protected HandlerExecutionChain | Returns: the HandlerExecutionChain (nevernull)the resolved handler instance (never handler, HttpServletRequest null)current HTTP request request)Build a |
| protected abstract Object | Returns: the corresponding handler instance, ornull if none foundcurrent HTTP request request)Look up a handler for the given request, returning |
| protected final MappedInterceptor[] | |
| public int | |
| public PathMatcher | |
| public PathPatternParser | getPatternParser()
Return the |
| private RequestPath | |
| public UrlPathHelper | |
| protected boolean | hasCorsConfigurationSource(Object handler)
Return |
| protected void | initApplicationContext()
Overrides org. Initializes the interceptors. |
| protected void | initInterceptors()
Initialize the specified interceptors adapting
|
| protected String | |
| public void | setAlwaysUseFullPath(boolean alwaysUseFullPath)
Deprecated
since 6.0. as of 6.0, in favor of using
setUrlPathHelper(UrlPathHelper)
Shortcut to same property on the configured |
| public void | setBeanName(String
the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the name)BeanFactoryUtils#originalBeanName(String)
method to extract the original bean name (without suffix), if desired.Implements org. Set the name of the bean in the bean factory that created this bean. |
| public void | setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations)
Set "global" CORS configuration mappings. |
| public void | setCorsConfigurationSource(CorsConfigurationSource source)
Set a |
| public void | setCorsProcessor(CorsProcessor corsProcessor)
Configure a custom |
| public void | |
| public void | setInterceptors(Object...
array of handler interceptors interceptors)Set the interceptors to apply for all handlers mapped by this handler mapping. |
| public void | |
| public void | |
| public void | setPatternParser(PathPatternParser
the parser to use patternParser)Set the |
| public void | setRemoveSemicolonContent(boolean removeSemicolonContent)
Deprecated
since 6.0. as of 6.0, in favor of using
setUrlPathHelper(UrlPathHelper)
Shortcut to same property on the underlying |
| public void | setUrlDecode(boolean urlDecode)
Deprecated
since 6.0. as of 6.0, in favor of using
setUrlPathHelper(UrlPathHelper)
Shortcut to same property on the underlying |
| public void | setUrlPathHelper(UrlPathHelper urlPathHelper)
Configure the UrlPathHelper to use for resolution of lookup paths. |
| public boolean | usesPathPatterns()
Overrides default org. Return "true" if this |
| adaptedInterceptors | back to summary |
|---|---|
| private final List<HandlerInterceptor> adaptedInterceptors | |
| beanName | back to summary |
|---|---|
| private String beanName
| |
| corsConfigurationSource | back to summary |
|---|---|
| private CorsConfigurationSource corsConfigurationSource
| |
| corsProcessor | back to summary |
|---|---|
| private CorsProcessor corsProcessor | |
| defaultHandler | back to summary |
|---|---|
| private Object defaultHandler
| |
| interceptors | back to summary |
|---|---|
| private final List<Object> interceptors | |
| mappingsLogger | back to summary |
|---|---|
| protected final Log mappingsLogger Dedicated "hidden" logger for request mappings. | |
| order | back to summary |
|---|---|
| private int order | |
| pathMatcher | back to summary |
|---|---|
| private PathMatcher pathMatcher | |
| patternParser | back to summary |
|---|---|
| private PathPatternParser patternParser
| |
| SUPPRESS_LOGGING_ATTRIBUTE | back to summary |
|---|---|
| pack-priv static final String SUPPRESS_LOGGING_ATTRIBUTE | |
| urlPathHelper | back to summary |
|---|---|
| private UrlPathHelper urlPathHelper | |
| AbstractHandlerMapping | back to summary |
|---|---|
| public AbstractHandlerMapping() | |
| adaptInterceptor | back to summary |
|---|---|
| protected HandlerInterceptor adaptInterceptor(Object interceptor) Adapt the given interceptor object to By default, the supported interceptor types are
| |
| detectMappedInterceptors | back to summary |
|---|---|
| protected void detectMappedInterceptors(List<HandlerInterceptor> mappedInterceptors) Detect beans of type This is called in addition to any
| |
| extendInterceptors | back to summary |
|---|---|
| protected void extendInterceptors(List<Object> interceptors) Extension hook that subclasses can override to register additional interceptors,
given the configured interceptors (see Will be invoked before The default implementation is empty. | |
| formatMappingName | back to summary |
|---|---|
| protected String formatMappingName() | |
| getAdaptedInterceptors | back to summary |
|---|---|
| public final HandlerInterceptor[] getAdaptedInterceptors() Return all configured interceptors adapted to
| |
| getCorsConfiguration | back to summary |
|---|---|
| protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) Retrieve the CORS configuration for the given handler.
| |
| getCorsConfigurationSource | back to summary |
|---|---|
| public CorsConfigurationSource getCorsConfigurationSource() Return the
| |
| getCorsHandlerExecutionChain | back to summary |
|---|---|
| protected HandlerExecutionChain getCorsHandlerExecutionChain(HttpServletRequest request, HandlerExecutionChain chain, CorsConfiguration config) Update
| |
| getCorsProcessor | back to summary |
|---|---|
| public CorsProcessor getCorsProcessor() Return the configured | |
| getDefaultHandler | back to summary |
|---|---|
| public Object getDefaultHandler() Return the default handler for this handler mapping,
or
| |
| getHandler | back to summary |
|---|---|
| public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception Implements org. Look up a handler for the given request, falling back to the default handler if no specific one is found.
| |
| getHandlerExecutionChain | back to summary |
|---|---|
| protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request) Build a The default implementation builds a standard Note The passed-in handler object may be a raw handler or a
pre-built For simply adding an interceptor in a custom subclass, consider calling
| |
| getHandlerInternal | back to summary |
|---|---|
| protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception Look up a handler for the given request, returning On CORS pre-flight requests this method should return a match not for
the pre-flight request but for the expected actual request based on the URL
path, the HTTP methods from the "Access-Control-Request-Method" header, and
the headers from the "Access-Control-Request-Headers" header thus allowing
the CORS configuration to be obtained via Note This method may also return a pre-built
| |
| getMappedInterceptors | back to summary |
|---|---|
| protected final MappedInterceptor[] getMappedInterceptors() Return all configured
| |
| getOrder | back to summary |
|---|---|
| public int getOrder() Implements org. Doc from org. Get the order value of this object. Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet Same order values will result in arbitrary sort positions for the affected objects.
| |
| getPathMatcher | back to summary |
|---|---|
| public PathMatcher getPathMatcher() Return the | |
| getPatternParser | back to summary |
|---|---|
| public PathPatternParser getPatternParser() Return the
| |
| getRequestPath | back to summary |
|---|---|
| private RequestPath getRequestPath(HttpServletRequest request) | |
| getUrlPathHelper | back to summary |
|---|---|
| public UrlPathHelper getUrlPathHelper() Return the | |
| hasCorsConfigurationSource | back to summary |
|---|---|
| protected boolean hasCorsConfigurationSource(Object handler) Return
| |
| initApplicationContext | back to summary |
|---|---|
| protected void initApplicationContext() throws BeansException Overrides org. Initializes the interceptors.
| |
| initInterceptors | back to summary |
|---|---|
| protected void initInterceptors() Initialize the specified interceptors adapting
| |
| initLookupPath | back to summary |
|---|---|
| protected String initLookupPath(HttpServletRequest request) Initialize the path to use for request mapping. When parsed patterns are Otherwise for String pattern matching via
| |
| setAlwaysUseFullPath | back to summary |
|---|---|
| public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
Shortcut to same property on the configured Note This property is mutually exclusive with and
ignored when
| |
| setBeanName | back to summary |
|---|---|
| public void setBeanName(String name) Implements org. Doc from org. Set the name of the bean in the bean factory that created this bean. Invoked after population of normal bean properties but before an
init callback such as
| |
| setCorsConfigurations | back to summary |
|---|---|
| public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations) Set "global" CORS configuration mappings. The first matching URL pattern
determines the This is mutually exclusive with
| |
| setCorsConfigurationSource | back to summary |
|---|---|
| public void setCorsConfigurationSource(CorsConfigurationSource source) Set a This is mutually exclusive with
| |
| setCorsProcessor | back to summary |
|---|---|
| public void setCorsProcessor(CorsProcessor corsProcessor) Configure a custom By default
| |
| setDefaultHandler | back to summary |
|---|---|
| public void setDefaultHandler(Object defaultHandler) Set the default handler for this handler mapping. This handler will be returned if no specific mapping was found. Default is | |
| setInterceptors | back to summary |
|---|---|
| public void setInterceptors(Object... interceptors) Set the interceptors to apply for all handlers mapped by this handler mapping. Supported interceptor types are
| |
| setOrder | back to summary |
|---|---|
| public void setOrder(int order) Specify the order value for this HandlerMapping bean. The default value is | |
| setPathMatcher | back to summary |
|---|---|
| public void setPathMatcher(PathMatcher pathMatcher) Configure the PathMatcher to use. Note This property is mutually exclusive with and
ignored when By default this is | |
| setPatternParser | back to summary |
|---|---|
| public void setPatternParser(PathPatternParser patternParser) Set the Note: This property is mutually exclusive with the
below properties, all of which are not necessary for parsed patterns and
are ignored when a
By default, as of 6.0, this is set to a
| |
| setRemoveSemicolonContent | back to summary |
|---|---|
| public void setRemoveSemicolonContent(boolean removeSemicolonContent)
Shortcut to same property on the underlying Note This property is mutually exclusive with and
ignored when
| |
| setUrlDecode | back to summary |
|---|---|
| public void setUrlDecode(boolean urlDecode)
Shortcut to same property on the underlying Note This property is mutually exclusive with and
ignored when
| |
| setUrlPathHelper | back to summary |
|---|---|
| public void setUrlPathHelper(UrlPathHelper urlPathHelper) Configure the UrlPathHelper to use for resolution of lookup paths. Note This property is mutually exclusive with and
ignored when | |
| usesPathPatterns | back to summary |
|---|---|
| public boolean usesPathPatterns() Overrides default org. Return "true" if this
| |
| Modifier and Type | Field and Description |
|---|---|
| private final CorsConfiguration |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public CorsConfiguration | getCorsConfiguration(HttpServletRequest request)
Implements org. Return a |
| public boolean | preHandle(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response, Object chosen handler to execute, for type and/or instance evaluation handler)Overrides default org. Interception point before the execution of a handler. |
| config | back to summary |
|---|---|
| private final CorsConfiguration config
| |
| CorsInterceptor | back to summary |
|---|---|
| public CorsInterceptor(CorsConfiguration config) | |
| getCorsConfiguration | back to summary |
|---|---|
| public CorsConfiguration getCorsConfiguration(HttpServletRequest request) Implements org. Doc from org. Return a
| |
| preHandle | back to summary |
|---|---|
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception Overrides default org. Doc from org. Interception point before the execution of a handler. Called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler. DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically sending an HTTP error or writing a custom response. Note special considerations apply for asynchronous
request processing. For more details see
The default implementation returns
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | handleRequest(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response)Implements org. Process the given request, generating a response. |
| PreFlightHandler | back to summary |
|---|---|
| public PreFlightHandler(CorsConfiguration config) | |
| handleRequest | back to summary |
|---|---|
| public void handleRequest(HttpServletRequest request, HttpServletResponse response) Implements org. Doc from org. Process the given request, generating a response.
| |