Class RouterFunctionMapping
- All Implemented Interfaces:
- Aware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- Ordered,- ServletContextAware,- MatchableHandlerMapping,- HandlerMapping
HandlerMapping implementation that supports RouterFunctions.
 If no RouterFunction is provided at
 construction time, this mapping
 will detect all router functions in the application context, and consult them in
 order.
- Since:
- 5.2
- Author:
- Arjen Poutsma, Sebastien Deleuze, Brian Clozel
- 
Field SummaryFields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMappingmappingsLoggerFields inherited from class org.springframework.context.support.ApplicationObjectSupportloggerFields inherited from interface org.springframework.web.servlet.HandlerMappingBEST_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_ATTRIBUTEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate an emptyRouterFunctionMapping.RouterFunctionMapping(RouterFunction<?> routerFunction) Create aRouterFunctionMappingwith the givenRouterFunction.
- 
Method SummaryModifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.protected ObjectgetHandlerInternal(HttpServletRequest servletRequest) Look up a handler for the given request, returningnullif no specific one is found.Return the configuredRouterFunction.match(HttpServletRequest request, String pattern) Determine whether the request matches the given pattern.voidsetDetectHandlerFunctionsInAncestorContexts(boolean detectHandlerFunctionsInAncestorContexts) Set whether to detect handler functions in ancestor ApplicationContexts.voidsetMessageConverters(List<HttpMessageConverter<?>> messageConverters) Set the message body converters to use.voidsetRouterFunction(RouterFunction<?> routerFunction) Set the router function to map to.Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMappingadaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getPatternParser, getUrlPathHelper, hasCorsConfigurationSource, initApplicationContext, initInterceptors, initLookupPath, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setPatternParser, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper, usesPathPatternsMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupportgetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupportgetApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContextMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.HandlerMappinggetHandler, usesPathPatternsMethods inherited from interface org.springframework.web.servlet.handler.MatchableHandlerMappinggetPatternParser
- 
Constructor Details- 
RouterFunctionMappingpublic RouterFunctionMapping()Create an emptyRouterFunctionMapping.If this constructor is used, this mapping will detect all RouterFunctioninstances available in the application context.
- 
RouterFunctionMappingCreate aRouterFunctionMappingwith the givenRouterFunction.If this constructor is used, no application context detection will occur. - Parameters:
- routerFunction- the router function to use for mapping
 
 
- 
- 
Method Details- 
setRouterFunctionSet the router function to map to.If this property is used, no application context detection will occur. 
- 
getRouterFunctionReturn the configuredRouterFunction.Note: When router functions are detected from the ApplicationContext, this method may return nullif invoked prior toafterPropertiesSet().- Returns:
- the router function or null
 
- 
setMessageConvertersSet the message body converters to use.These converters are used to convert from and to HTTP requests and responses. 
- 
setDetectHandlerFunctionsInAncestorContextspublic 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. 
- 
afterPropertiesSetpublic void afterPropertiesSet()Description copied from interface: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. - Specified by:
- afterPropertiesSetin interface- InitializingBean
 
- 
getHandlerInternalDescription copied from class:AbstractHandlerMappingLook up a handler for the given request, returningnullif no specific one is found. This method is called byAbstractHandlerMapping.getHandler(jakarta.servlet.http.HttpServletRequest); anullreturn 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.- Specified by:
- getHandlerInternalin class- AbstractHandlerMapping
- Parameters:
- servletRequest- current HTTP request
- Returns:
- the corresponding handler instance, or nullif none found
- Throws:
- Exception- if there is an internal error
 
- 
matchDescription copied from interface:MatchableHandlerMappingDetermine whether the request matches the given pattern. Use this method whenMatchableHandlerMapping.getPatternParser()returnsnullwhich means that theHandlerMappingis using String pattern matching.- Specified by:
- matchin interface- MatchableHandlerMapping
- Parameters:
- request- the current request
- pattern- the pattern to match
- Returns:
- the result from request matching, or nullif none
 
 
-