Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.handler

public abstract Class AbstractHandlerMapping

extends WebApplicationObjectSupport
implements HandlerMapping, Ordered, BeanNameAware
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.Aware, org.springframework.core.Ordered, org.springframework.web.servlet.HandlerMapping
Known Direct Subclasses
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping, org.springframework.web.servlet.handler.AbstractUrlHandlerMapping, org.springframework.web.servlet.function.support.RouterFunctionMapping
Imports
java.util.ArrayList, .Arrays, .List, .Map, jakarta.servlet.DispatcherType, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.apache.commons.logging.Log, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanFactoryUtils, .BeanNameAware, org.springframework.core.Ordered, org.springframework.core.log.LogDelegateFactory, org.springframework.http.server.RequestPath, org.springframework.lang.Nullable, org.springframework.util.AntPathMatcher, .Assert, .CollectionUtils, .PathMatcher, org.springframework.web.HttpRequestHandler, org.springframework.web.context.request.WebRequestInterceptor, org.springframework.web.context.request.async.WebAsyncManager, .WebAsyncUtils, org.springframework.web.context.support.WebApplicationObjectSupport, org.springframework.web.cors.CorsConfiguration, .CorsConfigurationSource, .CorsProcessor, .CorsUtils, .DefaultCorsProcessor, .UrlBasedCorsConfigurationSource, org.springframework.web.servlet.DispatcherServlet, .HandlerExecutionChain, .HandlerInterceptor, .HandlerMapping, org.springframework.web.util.ServletRequestPathUtils, .UrlPathHelper, org.springframework.web.util.pattern.PathPattern, .PathPatternParser

Abstract base class for 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.

Authors
Juergen Hoeller, Rossen Stoyanchev, Sam Brannen
Since
07.04.2003
See Also
getHandlerInternal, setDefaultHandler, setInterceptors, org.springframework.web.servlet.HandlerInterceptor

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private final List<HandlerInterceptor>
private String
private CorsConfigurationSource
private CorsProcessor
private Object
private final List<Object>
protected final Log
mappingsLogger

Dedicated "hidden" logger for request mappings.

private int
private PathMatcher
private PathPatternParser
pack-priv static final String
private UrlPathHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected HandlerInterceptor

Returns:

the interceptor downcast or adapted to HandlerInterceptor
adaptInterceptor
(Object
the interceptor
interceptor
)

Adapt the given interceptor object to HandlerInterceptor.

protected void
detectMappedInterceptors(List<HandlerInterceptor>
an empty list to add to
mappedInterceptors
)

Detect beans of type MappedInterceptor and add them to the list of mapped interceptors.

protected void
extendInterceptors(List<Object>
the configured interceptor List (never null), allowing to add further interceptors before as well as after the existing interceptors
interceptors
)

Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see setInterceptors).

protected String
public final HandlerInterceptor[]

Returns:

the array of configured interceptors, or null if none are configured; this method also returns null if called too early, or more specifically before org.springframework.context.ApplicationContextAware#setApplicationContext.
getAdaptedInterceptors
()

Return all configured interceptors adapted to HandlerInterceptor.

protected CorsConfiguration

Returns:

the CORS configuration for the handler, or null if none
getCorsConfiguration
(Object
the handler to check (never null).
handler
,
HttpServletRequest
the current request.
request
)

Retrieve the CORS configuration for the given handler.

public CorsConfigurationSource
getCorsConfigurationSource()

Return the configured CorsConfigurationSource, if any.

protected HandlerExecutionChain
getCorsHandlerExecutionChain(HttpServletRequest
the current request
request
,
HandlerExecutionChain
the chain to update
chain
,
CorsConfiguration
the CORS configuration applicable to the handler
config
)

Update HandlerExecutionChain for CORS requests, inserting an interceptor at the start of the chain to perform CORS checks, and also using a no-op handler for preflight requests.

public CorsProcessor
getCorsProcessor()

Return the configured CorsProcessor.

public Object
getDefaultHandler()

Return the default handler for this handler mapping, or null if none.

public final HandlerExecutionChain

Returns:

the corresponding handler instance, or the default handler
getHandler
(HttpServletRequest
current HTTP request
request
)

Implements org.springframework.web.servlet.HandlerMapping.getHandler.

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 (never null)
getHandlerExecutionChain
(Object
the resolved handler instance (never null)
handler
,
HttpServletRequest
current HTTP request
request
)

Build a HandlerExecutionChain for the given handler, including applicable interceptors.

protected abstract Object

Returns:

the corresponding handler instance, or null if none found
getHandlerInternal
(HttpServletRequest
current HTTP request
request
)

Look up a handler for the given request, returning null if no specific one is found.

protected final MappedInterceptor[]

Returns:

the array of MappedInterceptors, or null if none
getMappedInterceptors
()

Return all configured MappedInterceptors as an array.

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.

public PathMatcher
getPathMatcher()

Return the configured PathMatcher.

public PathPatternParser
getPatternParser()

Return the configured PathPatternParser, or null otherwise which indicates that String pattern matching with AntPathMatcher is enabled instead.

private RequestPath
public UrlPathHelper
getUrlPathHelper()

Return the configured UrlPathHelper.

protected boolean
hasCorsConfigurationSource(Object handler)

Return true if there is a CorsConfigurationSource for this handler.

protected void
protected void
initInterceptors()

Initialize the specified interceptors adapting WebRequestInterceptors to HandlerInterceptor.

protected String
initLookupPath(HttpServletRequest request)

Initialize the path to use for request mapping.

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 UrlPathHelper.

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 BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.
name
)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

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 CorsConfigurationSource for "global" CORS config.

public void
setCorsProcessor(CorsProcessor corsProcessor)

Configure a custom CorsProcessor to use to apply the matched CorsConfiguration for a request.

public void
setDefaultHandler(Object defaultHandler)

Set the default handler for this handler mapping.

public void
setInterceptors(Object...
array of handler interceptors
interceptors
)

Set the interceptors to apply for all handlers mapped by this handler mapping.

public void
setOrder(int order)

Specify the order value for this HandlerMapping bean.

public void
setPathMatcher(PathMatcher pathMatcher)

Configure the PathMatcher to use.

public void
setPatternParser(PathPatternParser
the parser to use
patternParser
)

Set the PathPatternParser to parse patterns with for URL path matching.

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 UrlPathHelper.

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 UrlPathHelper.

public void
setUrlPathHelper(UrlPathHelper urlPathHelper)

Configure the UrlPathHelper to use for resolution of lookup paths.

public boolean
usesPathPatterns()

Overrides default org.springframework.web.servlet.HandlerMapping.usesPathPatterns.

Return "true" if this HandlerMapping has been enabled to use parsed PathPatterns.

Inherited from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContextgetTempDirgetWebApplicationContextinitApplicationContextinitServletContextisContextRequiredsetServletContext

Field Detail

adaptedInterceptorsback to summary
private final List<HandlerInterceptor> adaptedInterceptors
beanNameback to summary
private String beanName
Annotations
@Nullable
corsConfigurationSourceback to summary
private CorsConfigurationSource corsConfigurationSource
Annotations
@Nullable
corsProcessorback to summary
private CorsProcessor corsProcessor
defaultHandlerback to summary
private Object defaultHandler
Annotations
@Nullable
interceptorsback to summary
private final List<Object> interceptors
mappingsLoggerback to summary
protected final Log mappingsLogger

Dedicated "hidden" logger for request mappings.

orderback to summary
private int order
pathMatcherback to summary
private PathMatcher pathMatcher
patternParserback to summary
private PathPatternParser patternParser
Annotations
@Nullable
SUPPRESS_LOGGING_ATTRIBUTEback to summary
pack-priv static final String SUPPRESS_LOGGING_ATTRIBUTE
urlPathHelperback to summary
private UrlPathHelper urlPathHelper

Constructor Detail

AbstractHandlerMappingback to summary
public AbstractHandlerMapping()

Method Detail

adaptInterceptorback to summary
protected HandlerInterceptor adaptInterceptor(Object interceptor)

Adapt the given interceptor object to HandlerInterceptor.

By default, the supported interceptor types are HandlerInterceptor and WebRequestInterceptor. Each given WebRequestInterceptor is wrapped with WebRequestHandlerInterceptorAdapter.

Parameters
interceptor:Object

the interceptor

Returns:HandlerInterceptor

the interceptor downcast or adapted to HandlerInterceptor

See Also
org.springframework.web.servlet.HandlerInterceptor, org.springframework.web.context.request.WebRequestInterceptor, WebRequestHandlerInterceptorAdapter
detectMappedInterceptorsback to summary
protected void detectMappedInterceptors(List<HandlerInterceptor> mappedInterceptors)

Detect beans of type MappedInterceptor and add them to the list of mapped interceptors.

This is called in addition to any MappedInterceptors that may have been provided via setInterceptors, by default adding all beans of type MappedInterceptor from the current context and its ancestors. Subclasses can override and refine this policy.

Parameters
mappedInterceptors:List<HandlerInterceptor>

an empty list to add to

extendInterceptorsback to summary
protected void extendInterceptors(List<Object> interceptors)

Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see setInterceptors).

Will be invoked before initInterceptors() adapts the specified interceptors into HandlerInterceptor instances.

The default implementation is empty.

Parameters
interceptors:List<Object>

the configured interceptor List (never null), allowing to add further interceptors before as well as after the existing interceptors

formatMappingNameback to summary
protected String formatMappingName()
getAdaptedInterceptorsback to summary
public final HandlerInterceptor[] getAdaptedInterceptors()

Return all configured interceptors adapted to HandlerInterceptor.

Returns:HandlerInterceptor[]

the array of configured interceptors, or null if none are configured; this method also returns null if called too early, or more specifically before org.springframework.context.ApplicationContextAware#setApplicationContext.

Annotations
@Nullable
getCorsConfigurationback to summary
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request)

Retrieve the CORS configuration for the given handler.

Parameters
handler:Object

the handler to check (never null).

request:HttpServletRequest

the current request.

Returns:CorsConfiguration

the CORS configuration for the handler, or null if none

Annotations
@Nullable
Since
4.2
getCorsConfigurationSourceback to summary
public CorsConfigurationSource getCorsConfigurationSource()

Return the configured CorsConfigurationSource, if any.

Annotations
@Nullable
Since
5.3
getCorsHandlerExecutionChainback to summary
protected HandlerExecutionChain getCorsHandlerExecutionChain(HttpServletRequest request, HandlerExecutionChain chain, CorsConfiguration config)

Update HandlerExecutionChain for CORS requests, inserting an interceptor at the start of the chain to perform CORS checks, and also using a no-op handler for preflight requests.

Parameters
request:HttpServletRequest

the current request

chain:HandlerExecutionChain

the chain to update

config:CorsConfiguration

the CORS configuration applicable to the handler

Since
4.2
getCorsProcessorback to summary
public CorsProcessor getCorsProcessor()

Return the configured CorsProcessor.

getDefaultHandlerback to summary
public Object getDefaultHandler()

Return the default handler for this handler mapping, or null if none.

Annotations
@Nullable
getHandlerback to summary
public final HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception

Implements org.springframework.web.servlet.HandlerMapping.getHandler.

Look up a handler for the given request, falling back to the default handler if no specific one is found.

Parameters
request:HttpServletRequest

current HTTP request

Returns:HandlerExecutionChain

the corresponding handler instance, or the default handler

Annotations
@Override
@Nullable
Exceptions
Exception:

Doc from org.springframework.web.servlet.HandlerMapping.getHandler.

if there is an internal error

See Also
getHandlerInternal
getHandlerExecutionChainback to summary
protected HandlerExecutionChain getHandlerExecutionChain(Object handler, HttpServletRequest request)

Build a HandlerExecutionChain for the given handler, including applicable interceptors.

The default implementation builds a standard HandlerExecutionChain with the given handler, the common interceptors of the handler mapping, and any MappedInterceptors matching to the current request URL. Interceptors are added in the order they were registered. Subclasses may override this in order to extend/rearrange the list of interceptors.

Note

The passed-in handler object may be a raw handler or a pre-built HandlerExecutionChain. This method should handle those two cases explicitly, either building a new HandlerExecutionChain or extending the existing chain.

For simply adding an interceptor in a custom subclass, consider calling super.getHandlerExecutionChain(handler, request) and invoking HandlerExecutionChain#addInterceptor on the returned chain object.

Parameters
handler:Object

the resolved handler instance (never null)

request:HttpServletRequest

current HTTP request

Returns:HandlerExecutionChain

the HandlerExecutionChain (never null)

See Also
getAdaptedInterceptors()
getHandlerInternalback to summary
protected abstract Object getHandlerInternal(HttpServletRequest request) throws Exception

Look up a handler for the given request, returning null if no specific one is found. This method is called by getHandler; a null return value will lead to the default handler, if one is set.

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 getCorsConfiguration(Object, HttpServletRequest),

Note

This method may also return a pre-built HandlerExecutionChain, combining a handler object with dynamically determined interceptors. Statically specified interceptors will get merged into such an existing chain.

Parameters
request:HttpServletRequest

current HTTP request

Returns:Object

the corresponding handler instance, or null if none found

Annotations
@Nullable
Exceptions
Exception:
if there is an internal error
getMappedInterceptorsback to summary
protected final MappedInterceptor[] getMappedInterceptors()

Return all configured MappedInterceptors as an array.

Returns:MappedInterceptor[]

the array of MappedInterceptors, or null if none

Annotations
@Nullable
getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

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 load-on-startup values).

Same order values will result in arbitrary sort positions for the affected objects.

Returns:int

the order value

Annotations
@Override
getPathMatcherback to summary
public PathMatcher getPathMatcher()

Return the configured PathMatcher.

getPatternParserback to summary
public PathPatternParser getPatternParser()

Return the configured PathPatternParser, or null otherwise which indicates that String pattern matching with AntPathMatcher is enabled instead.

Annotations
@Nullable
Since
5.3
getRequestPathback to summary
private RequestPath getRequestPath(HttpServletRequest request)
getUrlPathHelperback to summary
public UrlPathHelper getUrlPathHelper()

Return the configured UrlPathHelper.

hasCorsConfigurationSourceback to summary
protected boolean hasCorsConfigurationSource(Object handler)

Return true if there is a CorsConfigurationSource for this handler.

Since
5.2
initApplicationContextback to summary
protected void initApplicationContext() throws BeansException

Overrides org.springframework.context.support.ApplicationObjectSupport.initApplicationContext.

Initializes the interceptors.

Annotations
@Override
Exceptions
BeansException:

Doc from org.springframework.context.support.ApplicationObjectSupport.initApplicationContext.

if thrown by ApplicationContext methods

See Also
extendInterceptors(java.util.List), initInterceptors()
initInterceptorsback to summary
protected void initInterceptors()

Initialize the specified interceptors adapting WebRequestInterceptors to HandlerInterceptor.

See Also
setInterceptors, adaptInterceptor
initLookupPathback to summary
protected String initLookupPath(HttpServletRequest request)

Initialize the path to use for request mapping.

When parsed patterns are enabled a parsed RequestPath is expected to have been parsed externally by the org.springframework.web.servlet.DispatcherServlet or org.springframework.web.filter.ServletRequestPathFilter.

Otherwise for String pattern matching via PathMatcher the path is resolved by this method.

Since
5.3
setAlwaysUseFullPathback to summary
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 UrlPathHelper.

Note

This property is mutually exclusive with and ignored when setPatternParser(PathPatternParser) is set.

Annotations
@Deprecated
since:6.0
See Also
org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath(boolean)
setBeanNameback to summary
public void setBeanName(String name)

Implements org.springframework.beans.factory.BeanNameAware.setBeanName.

Doc from org.springframework.beans.factory.BeanNameAware.setBeanName.

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 InitializingBean#afterPropertiesSet() or a custom init-method.

Parameters
name: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 BeanFactoryUtils#originalBeanName(String) method to extract the original bean name (without suffix), if desired.

Annotations
@Override
setCorsConfigurationsback to summary
public void setCorsConfigurations(Map<String, CorsConfiguration> corsConfigurations)

Set "global" CORS configuration mappings. The first matching URL pattern determines the CorsConfiguration to use which is then further combined with the CorsConfiguration for the selected handler.

This is mutually exclusive with setCorsConfigurationSource(CorsConfigurationSource).

Since
4.2
See Also
setCorsProcessor(CorsProcessor)
setCorsConfigurationSourceback to summary
public void setCorsConfigurationSource(CorsConfigurationSource source)

Set a CorsConfigurationSource for "global" CORS config. The CorsConfiguration determined by the source is combined with the CorsConfiguration for the selected handler.

This is mutually exclusive with setCorsConfigurations(Map).

Since
5.1
See Also
setCorsProcessor(CorsProcessor)
setCorsProcessorback to summary
public void setCorsProcessor(CorsProcessor corsProcessor)

Configure a custom CorsProcessor to use to apply the matched CorsConfiguration for a request.

By default DefaultCorsProcessor is used.

Since
4.2
setDefaultHandlerback 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 null, indicating no default handler.

setInterceptorsback to summary
public void setInterceptors(Object... interceptors)

Set the interceptors to apply for all handlers mapped by this handler mapping.

Supported interceptor types are HandlerInterceptor, WebRequestInterceptor, and MappedInterceptor. Mapped interceptors apply only to request URLs that match its path patterns. Mapped interceptor beans are also detected by type during initialization.

Parameters
interceptors:Object[]

array of handler interceptors

See Also
adaptInterceptor, org.springframework.web.servlet.HandlerInterceptor, org.springframework.web.context.request.WebRequestInterceptor, MappedInterceptor
setOrderback to summary
public void setOrder(int order)

Specify the order value for this HandlerMapping bean.

The default value is Ordered.LOWEST_PRECEDENCE, meaning non-ordered.

See Also
org.springframework.core.Ordered#getOrder()
setPathMatcherback to summary
public void setPathMatcher(PathMatcher pathMatcher)

Configure the PathMatcher to use.

Note

This property is mutually exclusive with and ignored when setPatternParser(PathPatternParser) is set.

By default this is AntPathMatcher.

See Also
org.springframework.util.AntPathMatcher
setPatternParserback to summary
public void setPatternParser(PathPatternParser patternParser)

Set the PathPatternParser to parse patterns with for URL path matching. Parsed patterns provide a more modern and efficient alternative to String path matching via AntPathMatcher.

Note: This property is mutually exclusive with the below properties, all of which are not necessary for parsed patterns and are ignored when a PathPatternParser is available:

By default, as of 6.0, this is set to a PathPatternParser instance with default settings and therefore use of parsed patterns is enabled. Set this to null to switch to String path matching via AntPathMatcher instead.

Parameters
patternParser:PathPatternParser

the parser to use

Since
5.3
setRemoveSemicolonContentback to summary
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 UrlPathHelper.

Note

This property is mutually exclusive with and ignored when setPatternParser(PathPatternParser) is set.

Annotations
@Deprecated
since:6.0
See Also
org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)
setUrlDecodeback to summary
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 UrlPathHelper.

Note

This property is mutually exclusive with and ignored when setPatternParser(PathPatternParser) is set.

Annotations
@Deprecated
since:6.0
See Also
org.springframework.web.util.UrlPathHelper#setUrlDecode(boolean)
setUrlPathHelperback 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 setPatternParser(PathPatternParser) is set.

usesPathPatternsback to summary
public boolean usesPathPatterns()

Overrides default org.springframework.web.servlet.HandlerMapping.usesPathPatterns.

Return "true" if this HandlerMapping has been enabled to use parsed PathPatterns.

Annotations
@Override
org.springframework.web.servlet.handler back to summary

private Class AbstractHandlerMapping.CorsInterceptor

extends Object
implements HandlerInterceptor, CorsConfigurationSource
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.handler.AbstractHandlerMapping.CorsInterceptor
All Implemented Interfaces
org.springframework.web.cors.CorsConfigurationSource, org.springframework.web.servlet.HandlerInterceptor
Known Direct Subclasses
org.springframework.web.servlet.handler.AbstractHandlerMapping.PreFlightHandler

Field Summary

Modifier and TypeField and Description
private final CorsConfiguration

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CorsConfiguration
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.springframework.web.servlet.HandlerInterceptor.preHandle.

Interception point before the execution of a handler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configback to summary
private final CorsConfiguration config
Annotations
@Nullable

Constructor Detail

CorsInterceptorback to summary
public CorsInterceptor(CorsConfiguration config)

Method Detail

getCorsConfigurationback to summary
public CorsConfiguration getCorsConfiguration(HttpServletRequest request)

Implements org.springframework.web.cors.CorsConfigurationSource.getCorsConfiguration.

Doc from org.springframework.web.cors.CorsConfigurationSource.getCorsConfiguration.

Return a CorsConfiguration based on the incoming request.

Returns:CorsConfiguration

the associated CorsConfiguration, or null if none

Annotations
@Override
@Nullable
preHandleback to summary
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception

Overrides default org.springframework.web.servlet.HandlerInterceptor.preHandle.

Doc from org.springframework.web.servlet.HandlerInterceptor.preHandle.

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 org.springframework.web.servlet.AsyncHandlerInterceptor.

The default implementation returns true.

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handler:Object

chosen handler to execute, for type and/or instance evaluation

Returns:boolean

true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherServlet assumes that this interceptor has already dealt with the response itself.

Annotations
@Override
Exceptions
Exception:
in case of errors
org.springframework.web.servlet.handler back to summary

private Class AbstractHandlerMapping.PreFlightHandler

extends CorsInterceptor
implements HttpRequestHandler
Class Inheritance
All Implemented Interfaces
org.springframework.web.HttpRequestHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
handleRequest(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
)

Implements org.springframework.web.HttpRequestHandler.handleRequest.

Process the given request, generating a response.

Inherited from org.springframework.web.servlet.handler.AbstractHandlerMapping.CorsInterceptor:
getCorsConfigurationpreHandle

Constructor Detail

PreFlightHandlerback to summary
public PreFlightHandler(CorsConfiguration config)

Method Detail

handleRequestback to summary
public void handleRequest(HttpServletRequest request, HttpServletResponse response)

Implements org.springframework.web.HttpRequestHandler.handleRequest.

Doc from org.springframework.web.HttpRequestHandler.handleRequest.

Process the given request, generating a response.

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

Annotations
@Override