Class HandlerMappingIntrospector
java.lang.Object
org.springframework.web.servlet.handler.HandlerMappingIntrospector
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
,org.springframework.web.cors.CorsConfigurationSource
public class HandlerMappingIntrospector
extends Object
implements org.springframework.web.cors.CorsConfigurationSource, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Helper class to get information from the
HandlerMapping
that would
serve a specific request.
Provides the following methods:
getMatchableHandlerMapping(jakarta.servlet.http.HttpServletRequest)
— obtain aHandlerMapping
to check request-matching criteria against.getCorsConfiguration(jakarta.servlet.http.HttpServletRequest)
— obtain the CORS configuration for the request.
Note: This is primarily an SPI to allow Spring Security to align its pattern matching with the same pattern matching that would be used in Spring MVC for a given request, in order to avoid security issues. Use of this introspector should be avoided for other purposes because it incurs the overhead of resolving the handler for a request.
- Since:
- 4.3.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
org.springframework.web.cors.CorsConfiguration
getCorsConfiguration
(HttpServletRequest request) Return the configured or detectedHandlerMapping
s.Find theHandlerMapping
that would handle the given request and return it as aMatchableHandlerMapping
that can be used to test request-matching criteria.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
HandlerMappingIntrospector
public HandlerMappingIntrospector()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
getHandlerMappings
Return the configured or detectedHandlerMapping
s. -
getMatchableHandlerMapping
@Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception Find theHandlerMapping
that would handle the given request and return it as aMatchableHandlerMapping
that can be used to test request-matching criteria.If the matching HandlerMapping is not an instance of
MatchableHandlerMapping
, an IllegalStateException is raised.- Parameters:
request
- the current request- Returns:
- the resolved matcher, or
null
- Throws:
Exception
- if any of the HandlerMapping's raise an exception
-
getCorsConfiguration
@Nullable public org.springframework.web.cors.CorsConfiguration getCorsConfiguration(HttpServletRequest request) - Specified by:
getCorsConfiguration
in interfaceorg.springframework.web.cors.CorsConfigurationSource
-