类 AbstractUrlHandlerMapping
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.context.ApplicationContextAware,cn.taketoday.context.expression.EmbeddedValueResolverAware,cn.taketoday.core.Ordered,HandlerMapping
HandlerMapping implementations.
Supports literal matches and pattern matches such as "/test/*", "/test/**",
and others. For details on pattern syntax refer to PathPattern
All path patterns are checked in order to find the most exact match for the current request path where the "most exact" is the longest path pattern that matches the current request path.
- 从以下版本开始:
- 3.0 2020/12/23 15:56
- 作者:
- Juergen Hoeller, Arjen Poutsma, Harry Yang
-
字段概要
字段修饰符和类型字段说明private final LinkedHashMap<String,Object> private booleanprivate final LinkedHashMap<PathPattern,Object> private Object从类继承的字段 cn.taketoday.web.handler.AbstractHandlerMapping
embeddedValueResolver, mappingsLogger从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.HandlerMapping
HANDLER_MAPPING_BEAN_NAME从接口继承的字段 cn.taketoday.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voiddoPutPathPattern(PathPattern pathPattern, Object resolvedHandler) protected voidduPutHandler(String urlPath, Object resolvedHandler) private ObjectgetDirectMatch(String urlPath, RequestContext request) private StringgetHandlerDescription(Object handler) protected ObjectgetHandlerInternal(RequestContext request) Look up a handler for the URL path of the given request.Return the handler mappings, with the registered path or pattern as key and the handler object (or handler bean name in case of a lazy-init handler), as value.final Map<PathPattern,Object> Identical togetHandlerMap()but populatedReturn the root handler for this handler mapping (registered for "/"), ornullif none.protected ObjectlookupHandler(RequestContext request) Look up a handler instance for the given URL path.protected voidregisterHandler(String[] urlPaths, String beanName) Register the specified handler for the given URL paths.voidregisterHandler(String urlPath, Object handler) Register the specified handler for the given URL path.voidsetLazyInitHandlers(boolean lazyInitHandlers) Set whether to lazily initialize handlers.voidsetRootHandler(Object rootHandler) Set the root handler for this handler mapping, that is, the handler to be registered for the root path ("/").protected voidvalidateHandler(Object handler, RequestContext request) Validate the given handler against the current request.从类继承的方法 cn.taketoday.web.handler.AbstractHandlerMapping
detectMappedInterceptors, extendInterceptors, formatMappingName, getCorsConfiguration, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getHandlerInterceptors, getOrder, getPatternParser, hasCorsConfigurationSource, initApplicationContext, resolveEmbeddedVariables, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setEmbeddedValueResolver, setInterceptors, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
rootHandler
-
lazyInitHandlers
private boolean lazyInitHandlers -
handlerMap
-
pathPatternHandlerMap
-
-
构造器详细资料
-
AbstractUrlHandlerMapping
public AbstractUrlHandlerMapping()
-
-
方法详细资料
-
setRootHandler
Set the root handler for this handler mapping, that is, the handler to be registered for the root path ("/").Default is
null, indicating no root handler. -
getRootHandler
Return the root handler for this handler mapping (registered for "/"), ornullif none. -
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.
- 从以下版本开始:
- 4.0
-
getHandlerInternal
Look up a handler for the URL path of the given request.- 指定者:
getHandlerInternal在类中AbstractHandlerMapping- 参数:
request- current HTTP request context- 返回:
- the handler instance, or
nullif none found - 从以下版本开始:
- 4.0
-
lookupHandler
Look up a handler instance for the given URL path.- 参数:
request- current HTTP request- 返回:
- a matching handler, or
nullif not found - 从以下版本开始:
- 4.0
-
getDirectMatch
-
validateHandler
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 validaterequest- current HTTP request
-
registerHandler
protected void registerHandler(String[] urlPaths, String beanName) throws cn.taketoday.beans.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- 抛出:
cn.taketoday.beans.BeansException- if the handler couldn't be registeredIllegalStateException- if there is a conflicting handler registered- 从以下版本开始:
- 4.0
-
registerHandler
public void registerHandler(String urlPath, Object handler) throws cn.taketoday.beans.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)- 抛出:
cn.taketoday.beans.BeansException- if the handler couldn't be registeredIllegalStateException- if there is a conflicting handler registered
-
doPutPathPattern
-
duPutHandler
-
getHandlerDescription
-
getHandlerMap
Return the handler mappings, with the registered path or pattern as key and the handler object (or handler bean name in case of a lazy-init handler), as value. -
getPathPatternHandlerMap
Identical togetHandlerMap()but populated
-