类 RouterFunctionMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.handler.AbstractHandlerMapping
- org.springframework.web.servlet.function.support.RouterFunctionMapping
- 所有已实现的接口:
Aware
,BeanNameAware
,InitializingBean
,ApplicationContextAware
,Ordered
,ServletContextAware
,HandlerMapping
public class RouterFunctionMapping extends AbstractHandlerMapping implements InitializingBean
HandlerMapping
implementation that supportsRouterFunctions
.If no
RouterFunction
is provided at construction time, this mapping will detect all router functions in the application context, and consult them in order.- 从以下版本开始:
- 5.2
- 作者:
- Arjen Poutsma
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, LOOKUP_PATH, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 RouterFunctionMapping()
Create an emptyRouterFunctionMapping
.RouterFunctionMapping(RouterFunction<?> routerFunction)
Create aRouterFunctionMapping
with the givenRouterFunction
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected Object
getHandlerInternal(HttpServletRequest servletRequest)
Look up a handler for the given request, returningnull
if no specific one is found.RouterFunction<?>
getRouterFunction()
Return the configuredRouterFunction
.void
setDetectHandlerFunctionsInAncestorContexts(boolean detectHandlerFunctionsInAncestorContexts)
Set whether to detect handler functions in ancestor ApplicationContexts.void
setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
void
setRouterFunction(RouterFunction<?> routerFunction)
Set the router function to map to.从类继承的方法 org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, hasCorsConfigurationSource, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
RouterFunctionMapping
public RouterFunctionMapping()
Create an emptyRouterFunctionMapping
.If this constructor is used, this mapping will detect all
RouterFunction
instances available in the application context.
RouterFunctionMapping
public RouterFunctionMapping(RouterFunction<?> routerFunction)
Create aRouterFunctionMapping
with the givenRouterFunction
.If this constructor is used, no application context detection will occur.
- 参数:
routerFunction
- the router function to use for mapping
方法详细资料
setRouterFunction
public void setRouterFunction(@Nullable RouterFunction<?> routerFunction)
Set the router function to map to.If this property is used, no application context detection will occur.
getRouterFunction
@Nullable public RouterFunction<?> getRouterFunction()
Return the configuredRouterFunction
.Note: When router functions are detected from the ApplicationContext, this method may return
null
if invoked prior toafterPropertiesSet()
.- 返回:
- the router function or
null
setMessageConverters
public void setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
setDetectHandlerFunctionsInAncestorContexts
public void setDetectHandlerFunctionsInAncestorContexts(boolean detectHandlerFunctionsInAncestorContexts)
Set whether to detect handler functions in ancestor ApplicationContexts.Default is "false": Only handler functions in the current ApplicationContext will be detected, i.e. only in the context that this HandlerMapping itself is defined in (typically the current DispatcherServlet's context).
Switch this flag on to detect handler beans in ancestor contexts (typically the Spring root WebApplicationContext) as well.
afterPropertiesSet
public void afterPropertiesSet() throws Exception
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.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
- 抛出:
Exception
- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
getHandlerInternal
@Nullable protected Object getHandlerInternal(HttpServletRequest servletRequest) throws Exception
从类复制的说明:AbstractHandlerMapping
Look up a handler for the given request, returningnull
if no specific one is found. This method is called byAbstractHandlerMapping.getHandler(javax.servlet.http.HttpServletRequest)
; anull
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
AbstractHandlerMapping.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.- 指定者:
getHandlerInternal
在类中AbstractHandlerMapping
- 参数:
servletRequest
- current HTTP request- 返回:
- the corresponding handler instance, or
null
if none found - 抛出:
Exception
- if there is an internal error