类 WebContentInterceptor

    • 方法详细资料

      • setUrlDecode

        public void setUrlDecode​(boolean urlDecode)
        Set if context path and request URI should be URL-decoded. Both are returned undecoded by the Servlet API, in contrast to the servlet path.

        Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).

        Only relevant for the "cacheMappings" setting.

        另请参阅:
        setCacheMappings(java.util.Properties), UrlPathHelper.setUrlDecode(boolean)
      • setCacheMappings

        public void setCacheMappings​(Properties cacheMappings)
        Map specific URL paths to specific cache seconds.

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

        Supports direct matches, e.g. a registered "/test" matches "/test", and a various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher javadoc.

        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)
        另请参阅:
        WebContentGenerator.setCacheSeconds(int), AntPathMatcher
      • 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.

        Supports direct matches, e.g. a registered "/test" matches "/test", and a various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher javadoc.

        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 - URL paths that will map to the given CacheControl
        从以下版本开始:
        4.2
        另请参阅:
        WebContentGenerator.setCacheSeconds(int), AntPathMatcher
      • preHandle

        public boolean preHandle​(HttpServletRequest request,
                                 HttpServletResponse response,
                                 Object handler)
                          throws ServletException
        从接口复制的说明: HandlerInterceptor
        Intercept the execution of a handler. Called after HandlerMapping determined an appropriate handler object, but before HandlerAdapter invokes the handler.

        DispatcherServlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically sending a HTTP error or writing a custom response.

        Note: special considerations apply for asynchronous request processing. For more details see AsyncHandlerInterceptor.

        指定者:
        preHandle 在接口中 HandlerInterceptor
        参数:
        request - current HTTP request
        response - current HTTP response
        handler - chosen handler to execute, for type and/or instance evaluation
        返回:
        true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherServlet assumes that this interceptor has already dealt with the response itself.
        抛出:
        ServletException
      • lookupCacheControl

        protected CacheControl lookupCacheControl​(String urlPath)
        Look up a CacheControl instance for the given URL path.

        Supports direct matches, e.g. a registered "/test" matches "/test", and various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher class.

        参数:
        urlPath - URL the bean is mapped to
        返回:
        the associated CacheControl, or null if not found
        另请参阅:
        AntPathMatcher
      • lookupCacheSeconds

        protected Integer lookupCacheSeconds​(String urlPath)
        Look up a cacheSeconds integer value for the given URL path.

        Supports direct matches, e.g. a registered "/test" matches "/test", and various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher class.

        参数:
        urlPath - URL the bean is mapped to
        返回:
        the cacheSeconds integer value, or null if not found
        另请参阅:
        AntPathMatcher