类 HandlerMappingIntrospector
- java.lang.Object
- org.springframework.web.servlet.handler.HandlerMappingIntrospector
public class HandlerMappingIntrospector extends Object implements CorsConfigurationSource, ApplicationContextAware, InitializingBean
Helper class to get information from theHandlerMappingthat would serve a specific request.Provides the following methods:
getMatchableHandlerMapping(javax.servlet.http.HttpServletRequest)— obtain aHandlerMappingto check request-matching criteria against.getCorsConfiguration(javax.servlet.http.HttpServletRequest)— obtain the CORS configuration for the request.
- 从以下版本开始:
- 4.3.1
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 HandlerMappingIntrospector()Constructor for use withApplicationContextAware.HandlerMappingIntrospector(ApplicationContext context)已过时。as of 4.3.12, in favor ofsetApplicationContext(org.springframework.context.ApplicationContext)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.CorsConfigurationgetCorsConfiguration(HttpServletRequest request)Return aCorsConfigurationbased on the incoming request.List<HandlerMapping>getHandlerMappings()Return the configured HandlerMapping's.MatchableHandlerMappinggetMatchableHandlerMapping(HttpServletRequest request)Find theHandlerMappingthat would handle the given request and return it as aMatchableHandlerMappingthat can be used to test request-matching criteria.voidsetApplicationContext(ApplicationContext applicationContext)Set the ApplicationContext that this object runs in.
构造器详细资料
HandlerMappingIntrospector
public HandlerMappingIntrospector()
Constructor for use withApplicationContextAware.
HandlerMappingIntrospector
@Deprecated public HandlerMappingIntrospector(ApplicationContext context)
已过时。as of 4.3.12, in favor ofsetApplicationContext(org.springframework.context.ApplicationContext)Constructor that detects the configuredHandlerMappings in the givenApplicationContextor falls back on "DispatcherServlet.properties" like theDispatcherServlet.
方法详细资料
getHandlerMappings
public List<HandlerMapping> getHandlerMappings()
Return the configured HandlerMapping's.
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)andMessageSourceAware, if applicable.- 指定者:
setApplicationContext在接口中ApplicationContextAware- 参数:
applicationContext- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet在接口中InitializingBean
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.- 参数:
request- the current request- 返回:
- the resolved matcher, or
null - 抛出:
Exception- if any of the HandlerMapping's raise an exception
getCorsConfiguration
@Nullable public CorsConfiguration getCorsConfiguration(HttpServletRequest request)
从接口复制的说明:CorsConfigurationSourceReturn aCorsConfigurationbased on the incoming request.- 指定者:
getCorsConfiguration在接口中CorsConfigurationSource- 返回:
- the associated
CorsConfiguration, ornullif none