类 AbstractUrlHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.reactive.handler.AbstractHandlerMapping
- org.springframework.web.reactive.handler.AbstractUrlHandlerMapping
- 所有已实现的接口:
Aware
,BeanNameAware
,ApplicationContextAware
,Ordered
,HandlerMapping
- 直接已知子类:
SimpleUrlHandlerMapping
public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping
Abstract base class for URL-mappedHandlerMapping
implementations.Supports direct matches, e.g. a registered "/test" matches "/test", and various path pattern matches, e.g. a registered "/t*" pattern matches both "/test" and "/team", "/test/*" matches all paths under "/test", "/test/**" matches all paths below "/test". For details, see the
PathPattern
javadoc.Will search all path patterns to find the most specific match for the current request path. The most specific pattern is defined as the longest path pattern with the fewest captured variables and wildcards.
- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Brian Clozel
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.reactive.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AbstractUrlHandlerMapping()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<Object>
getHandlerInternal(ServerWebExchange exchange)
Look up a handler for the given request, returning an emptyMono
if no specific one is found.Map<PathPattern,Object>
getHandlerMap()
Return a read-only view of registered path patterns and handlers which may may be an actual handler instance or the bean name of lazily initialized handler.protected Object
lookupHandler(PathContainer lookupPath, ServerWebExchange exchange)
Look up a handler instance for the given URL lookup path.protected void
registerHandler(String[] urlPaths, String beanName)
Register the specified handler for the given URL paths.protected void
registerHandler(String urlPath, Object handler)
Register the specified handler for the given URL path.void
setLazyInitHandlers(boolean lazyInitHandlers)
Set whether to lazily initialize handlers.protected void
validateHandler(Object handler, ServerWebExchange exchange)
Validate the given handler against the current request.从类继承的方法 org.springframework.web.reactive.handler.AbstractHandlerMapping
formatMappingName, getCorsConfiguration, getCorsProcessor, getHandler, getOrder, getPathPatternParser, hasCorsConfigurationSource, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
AbstractUrlHandlerMapping
public AbstractUrlHandlerMapping()
方法详细资料
setLazyInitHandlers
public void setLazyInitHandlers(boolean lazyInitHandlers)
Set whether to lazily initialize handlers. Only applicable to singleton handlers, as prototypes are always lazily initialized. Default is "false", as eager initialization allows for more efficiency through referencing the controller objects directly.If you want to allow your controllers to be lazily initialized, make them "lazy-init" and set this flag to true. Just making them "lazy-init" will not work, as they are initialized through the references from the handler mapping in this case.
getHandlerMap
public final Map<PathPattern,Object> getHandlerMap()
Return a read-only view of registered path patterns and handlers which may may be an actual handler instance or the bean name of lazily initialized handler.
getHandlerInternal
public reactor.core.publisher.Mono<Object> getHandlerInternal(ServerWebExchange exchange)
从类复制的说明:AbstractHandlerMapping
Look up a handler for the given request, returning an emptyMono
if no specific one is found. This method is called byAbstractHandlerMapping.getHandler(org.springframework.web.server.ServerWebExchange)
.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.
- 指定者:
getHandlerInternal
在类中AbstractHandlerMapping
- 参数:
exchange
- current exchange- 返回:
Mono
for the matching handler, if any
lookupHandler
@Nullable protected Object lookupHandler(PathContainer lookupPath, ServerWebExchange exchange) throws Exception
Look up a handler instance for the given URL lookup path.Supports direct matches, e.g. a registered "/test" matches "/test", and various path pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the PathPattern class.
- 参数:
lookupPath
- the URL the handler is mapped toexchange
- the current exchange- 返回:
- the associated handler instance, or
null
if not found - 抛出:
Exception
- 另请参阅:
PathPattern
validateHandler
protected void validateHandler(Object handler, ServerWebExchange exchange)
Validate the given handler against the current request.The default implementation is empty. Can be overridden in subclasses, for example to enforce specific preconditions expressed in URL mappings.
- 参数:
handler
- the handler object to validateexchange
- current exchange
registerHandler
protected void registerHandler(String[] urlPaths, String beanName) throws BeansException, IllegalStateException
Register the specified handler for the given URL paths.- 参数:
urlPaths
- the URLs that the bean should be mapped tobeanName
- the name of the handler bean- 抛出:
BeansException
- if the handler couldn't be registeredIllegalStateException
- if there is a conflicting handler registered
registerHandler
protected void registerHandler(String urlPath, Object handler) throws BeansException, IllegalStateException
Register the specified handler for the given URL path.- 参数:
urlPath
- the URL the bean should be mapped tohandler
- the handler instance or handler bean name String (a bean name will automatically be resolved into the corresponding handler bean)- 抛出:
BeansException
- if the handler couldn't be registeredIllegalStateException
- if there is a conflicting handler registered