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 aHandlerMappingto 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidorg.springframework.web.cors.CorsConfigurationgetCorsConfiguration(HttpServletRequest request) Return the configured or detectedHandlerMappings.Find theHandlerMappingthat would handle the given request and return it as aMatchableHandlerMappingthat can be used to test request-matching criteria.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
HandlerMappingIntrospector
public HandlerMappingIntrospector()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
getHandlerMappings
Return the configured or detectedHandlerMappings. -
getMatchableHandlerMapping
@Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception Find theHandlerMappingthat would handle the given request and return it as aMatchableHandlerMappingthat 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:
getCorsConfigurationin interfaceorg.springframework.web.cors.CorsConfigurationSource
-