类 WebContentInterceptor
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.context.ApplicationContextAware,HandlerInterceptor
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
- 另请参阅:
-
PathMatcherAntPathMatcher
-
字段概要
字段修饰符和类型字段说明private final HashMap<PathPattern,CacheControl> private final HashMap<PathPattern,Integer> private final PathPatternParser从类继承的字段 cn.taketoday.web.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.HandlerInterceptor
EMPTY_ARRAY, NONE_RETURN_VALUE -
构造器概要
构造器构造器说明Default constructor withPathPatternParser.defaultInstance.Constructor with aPathPatternParserto parse patterns with. -
方法概要
修饰符和类型方法说明voidaddCacheMapping(CacheControl cacheControl, String... paths) Map specific URL paths to a specificCacheControl.booleanbeforeProcess(RequestContext request, Object handler) Before Handler process.protected CacheControlFind aCacheControlinstance for the given parsedpath.protected IntegerFind a cacheSeconds value for the given parsedpath.voidsetCacheMappings(Properties cacheMappings) Map settings for cache seconds to specific URL paths via patterns.从类继承的方法 cn.taketoday.web.WebContentGenerator
applyCacheControl, applyCacheSeconds, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isRequireSession, prepareResponse, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setVaryByRequestHeaders从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.web.HandlerInterceptor
afterProcess, intercept
-
字段详细资料
-
patternParser
-
cacheMappings
-
cacheControlMappings
-
-
构造器详细资料
-
WebContentInterceptor
public WebContentInterceptor()Default constructor withPathPatternParser.defaultInstance. -
WebContentInterceptor
Constructor with aPathPatternParserto parse patterns with.
-
-
方法详细资料
-
setCacheMappings
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
AntPathMatcherandPathPatternas well as the class-level Javadoc for details for when each is used. The syntax is largely the same withPathPatternmore 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
Map specific URL paths to a specificCacheControl.Overrides the default cache seconds setting of this interceptor. Can specify a empty
CacheControlinstance to exclude a URL path from default caching.For pattern syntax see
AntPathMatcherandPathPatternas well as the class-level Javadoc for details for when each is used. The syntax is largely the same withPathPatternmore 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- theCacheControlto usepaths- the URL paths that will map to the givenCacheControl- 另请参阅:
-
beforeProcess
从接口复制的说明:HandlerInterceptorBefore Handler process.- 指定者:
beforeProcess在接口中HandlerInterceptor- 参数:
request- Current request Contexthandler- Request handler ,HandlerMethod- 返回:
- If is it possible to execute the target handler
- 另请参阅:
-
lookupCacheControl
Find aCacheControlinstance for the given parsedpath. This is used when theHandlerMappinguses parsedPathPatterns.- 参数:
path- the path to match to- 返回:
- the matched
CacheControl, ornullif no match
-
lookupCacheSeconds
Find a cacheSeconds value for the given parsedpath. This is used when theHandlerMappinguses parsedPathPatterns.- 参数:
path- the path to match to- 返回:
- the matched cacheSeconds, or
nullif there is no match
-