类 AbstractUrlHandlerMapping

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.handler.AbstractHandlerMapping
cn.taketoday.web.handler.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
直接已知子类:
AbstractDetectingUrlHandlerMapping, SimpleUrlHandlerMapping

public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping
Abstract base class for URL-mapped 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
  • 字段详细资料

  • 构造器详细资料

    • AbstractUrlHandlerMapping

      public AbstractUrlHandlerMapping()
  • 方法详细资料

    • setRootHandler

      public void setRootHandler(@Nullable Object rootHandler)
      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

      @Nullable public Object getRootHandler()
      Return the root handler for this handler mapping (registered for "/"), or null if 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

      @Nullable protected Object getHandlerInternal(RequestContext request)
      Look up a handler for the URL path of the given request.
      指定者:
      getHandlerInternal 在类中 AbstractHandlerMapping
      参数:
      request - current HTTP request context
      返回:
      the handler instance, or null if none found
      从以下版本开始:
      4.0
    • lookupHandler

      @Nullable protected Object lookupHandler(RequestContext request)
      Look up a handler instance for the given URL path.
      参数:
      request - current HTTP request
      返回:
      a matching handler, or null if not found
      从以下版本开始:
      4.0
    • getDirectMatch

      @Nullable private Object getDirectMatch(String urlPath, RequestContext request)
    • validateHandler

      protected void validateHandler(Object handler, RequestContext request)
      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 validate
      request - 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 to
      beanName - the name of the handler bean
      抛出:
      cn.taketoday.beans.BeansException - if the handler couldn't be registered
      IllegalStateException - 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 to
      handler - 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 registered
      IllegalStateException - if there is a conflicting handler registered
    • doPutPathPattern

      protected void doPutPathPattern(PathPattern pathPattern, Object resolvedHandler)
    • duPutHandler

      protected void duPutHandler(String urlPath, Object resolvedHandler)
    • getHandlerDescription

      private String getHandlerDescription(Object handler)
    • getHandlerMap

      public final Map<String,Object> 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

      public final Map<PathPattern,Object> getPathPatternHandlerMap()
      Identical to getHandlerMap() but populated