类 WebContentInterceptor

java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.WebContentGenerator
cn.taketoday.web.handler.mvc.WebContentInterceptor
所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.context.ApplicationContextAware, HandlerInterceptor

public class WebContentInterceptor extends WebContentGenerator implements HandlerInterceptor
Handler interceptor that checks the request for supported methods and a required session and prepares the response by applying the configured cache settings.

Cache settings may be configured for specific URLs via path pattern with addCacheMapping(CacheControl, String...) and setCacheMappings(Properties), along with a fallback on default settings for all URLs via WebContentGenerator.setCacheControl(CacheControl).

Pattern matching can be done with PathMatcher or with parsed PathPatterns. The syntax is largely the same with the latter being more tailored for web usage and more efficient.

All the settings supported by this interceptor can also be set on AbstractController. This interceptor is mainly intended for applying checks and preparations to a set of controllers mapped by a HandlerMapping.

从以下版本开始:
4.0 2022/2/8 15:46
作者:
Juergen Hoeller, Brian Clozel, Rossen Stoyanchev, Harry Yang
另请参阅:
  • PathMatcher
  • AntPathMatcher
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • setCacheMappings

      public void setCacheMappings(Properties cacheMappings)
      Map settings for cache seconds to specific URL paths via patterns.

      Overrides the default cache seconds setting of this interceptor. Can specify "-1" to exclude a URL path from default caching.

      For pattern syntax see AntPathMatcher and PathPattern as well as the class-level Javadoc for details for when each is used. The syntax is largely the same with PathPattern more tailored for web usage.

      NOTE: Path patterns are not supposed to overlap. If a request matches several mappings, it is effectively undefined which one will apply (due to the lack of key ordering in java.util.Properties).

      参数:
      cacheMappings - a mapping between URL paths (as keys) and cache seconds (as values, need to be integer-parsable)
      另请参阅:
    • addCacheMapping

      public void addCacheMapping(CacheControl cacheControl, String... paths)
      Map specific URL paths to a specific CacheControl.

      Overrides the default cache seconds setting of this interceptor. Can specify a empty CacheControl instance to exclude a URL path from default caching.

      For pattern syntax see AntPathMatcher and PathPattern as well as the class-level Javadoc for details for when each is used. The syntax is largely the same with PathPattern more tailored for web usage.

      NOTE: Path patterns are not supposed to overlap. If a request matches several mappings, it is effectively undefined which one will apply (due to the lack of key ordering in the underlying java.util.HashMap).

      参数:
      cacheControl - the CacheControl to use
      paths - the URL paths that will map to the given CacheControl
      另请参阅:
    • beforeProcess

      public boolean beforeProcess(RequestContext request, Object handler)
      从接口复制的说明: HandlerInterceptor
      Before Handler process.
      指定者:
      beforeProcess 在接口中 HandlerInterceptor
      参数:
      request - Current request Context
      handler - Request handler , HandlerMethod
      返回:
      If is it possible to execute the target handler
      另请参阅:
    • lookupCacheControl

      @Nullable protected CacheControl lookupCacheControl(PathContainer path)
      Find a CacheControl instance for the given parsed path. This is used when the HandlerMapping uses parsed PathPatterns.
      参数:
      path - the path to match to
      返回:
      the matched CacheControl, or null if no match
    • lookupCacheSeconds

      @Nullable protected Integer lookupCacheSeconds(PathContainer path)
      Find a cacheSeconds value for the given parsed path. This is used when the HandlerMapping uses parsed PathPatterns.
      参数:
      path - the path to match to
      返回:
      the matched cacheSeconds, or null if there is no match