HandlerInterceptor and uses URL patterns to determine whether
it applies to a given request.
Pattern matching can be done with a PathMatcher or with a parsed
PathPattern. The syntax is largely the same with the latter being more
tailored for web usage and more efficient. The choice is driven by the
presence of a resolved
String lookupPath or a parsed RequestPath which in turn depends on the HandlerMapping
that matched the current request.
MappedInterceptor is supported by subclasses of
AbstractHandlerMethodMapping which detect beans of type MappedInterceptor
and also check if interceptors directly registered with it are of this type.
| Modifier and Type | Class and Description |
|---|---|
| private static class | MappedInterceptor.
Contains both the parsed |
| Modifier and Type | Field and Description |
|---|---|
| private static final PathMatcher | |
| private final MappedInterceptor. | |
| private final MappedInterceptor. | |
| private final HandlerInterceptor | |
| private PathMatcher |
| Access | Constructor and Description |
|---|---|
| public | MappedInterceptor(String[]
patterns to which requests must match, or null to
match all paths includePatterns, String[] patterns to which requests must not match excludePatterns, HandlerInterceptor the target interceptor interceptor, PathPatternParser a parser to use to pre-parse patterns into parser)PathPattern;
when not provided, PathPatternParser#defaultInstance is used.Create an instance with the given include and exclude patterns along with the target interceptor for the mappings. |
| public | MappedInterceptor(String[] includePatterns, HandlerInterceptor interceptor)
Variant of
|
| public | MappedInterceptor(String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor)
Variant of
|
| public | MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor)
Variant of
|
| public | MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor)
Variant of
|
| Modifier and Type | Method and Description |
|---|---|
| public void | afterCompletion(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response, Object the handler (or handler, Exception HandlerMethod) that started asynchronous
execution, for type and/or instance examinationany exception thrown on handler execution, if any; this does not
include exceptions that have been handled through an exception resolver ex)Overrides default org. Callback after completion of request processing, that is, after rendering the view. |
| public String[] | |
| public String[] | |
| public HandlerInterceptor | |
| public PathMatcher | |
| public String[] | getPathPatterns()
Deprecated
for removal since 6.1. since 6.1 in favor of
getIncludePathPatterns()
Get the include path patterns this interceptor is mapped to. |
| public boolean | Returns: true if the interceptor should be applied to the requestthe request to match to request)Check whether this interceptor is mapped to the request. |
| public boolean | Returns: true if the interceptor applies to the given request paththe current request path lookupPath, PathMatcher a path matcher for path pattern matching pathMatcher)
Deprecated
since 5.3. as of 5.3 in favor of
matches(HttpServletRequest)
Determine if there is a match for the given lookup path. |
| public void | postHandle(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response, Object the handler (or handler, ModelAndView HandlerMethod) that started asynchronous
execution, for type and/or instance examinationthe modelAndView)ModelAndView that the handler returned
(can also be null)Overrides default org. Interception point after successful execution of a handler. |
| public boolean | preHandle(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response, Object chosen handler to execute, for type and/or instance evaluation handler)Overrides default org. Interception point before the execution of a handler. |
| public void | setPathMatcher(PathMatcher pathMatcher)
Configure the PathMatcher to use to match URL paths with against include and exclude patterns. |
| defaultPathMatcher | back to summary |
|---|---|
| private static final PathMatcher defaultPathMatcher | |
| excludePatterns | back to summary |
|---|---|
| private final MappedInterceptor. | |
| includePatterns | back to summary |
|---|---|
| private final MappedInterceptor. | |
| interceptor | back to summary |
|---|---|
| private final HandlerInterceptor interceptor | |
| pathMatcher | back to summary |
|---|---|
| private PathMatcher pathMatcher | |
| MappedInterceptor | back to summary |
|---|---|
| public MappedInterceptor(String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor, PathPatternParser parser) Create an instance with the given include and exclude patterns along with the target interceptor for the mappings.
| |
| MappedInterceptor | back to summary |
|---|---|
| public MappedInterceptor(String[] includePatterns, HandlerInterceptor interceptor) Variant of
| |
| MappedInterceptor | back to summary |
|---|---|
| public MappedInterceptor(String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor) Variant of
| |
| MappedInterceptor | back to summary |
|---|---|
| public MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor) Variant of
| |
| MappedInterceptor | back to summary |
|---|---|
| public MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) Variant of
| |
| afterCompletion | back to summary |
|---|---|
| public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception Overrides default org. Doc from org. Callback after completion of request processing, that is, after rendering the view. Will be called on any outcome of handler execution, thus allows for proper resource cleanup. Note Will only be called if this interceptor's As with the Note special considerations apply for asynchronous
request processing. For more details see
The default implementation is empty.
| |
| getExcludePathPatterns | back to summary |
|---|---|
| public String[] getExcludePathPatterns() Get the exclude path patterns this interceptor is mapped to.
| |
| getIncludePathPatterns | back to summary |
|---|---|
| public String[] getIncludePathPatterns() Get the include path patterns this interceptor is mapped to.
| |
| getInterceptor | back to summary |
|---|---|
| public HandlerInterceptor getInterceptor() The target | |
| getPathMatcher | back to summary |
|---|---|
| public PathMatcher getPathMatcher() Get the configured PathMatcher. | |
| getPathPatterns | back to summary |
|---|---|
| public String[] getPathPatterns()
Get the include path patterns this interceptor is mapped to.
| |
| matches | back to summary |
|---|---|
| public boolean matches(HttpServletRequest request) Check whether this interceptor is mapped to the request. The request mapping path is expected to have been resolved externally. See also class-level Javadoc.
| |
| matches | back to summary |
|---|---|
| public boolean matches(String lookupPath, PathMatcher pathMatcher)
Determine if there is a match for the given lookup path.
| |
| postHandle | back to summary |
|---|---|
| public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception Overrides default org. Doc from org. Interception point after successful execution of a handler. Called after HandlerAdapter actually invoked the handler, but before the DispatcherServlet renders the view. Can expose additional model objects to the view via the given ModelAndView. 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 post-process an execution, getting applied in inverse order of the execution chain. Note special considerations apply for asynchronous
request processing. For more details see
The default implementation is empty.
| |
| preHandle | back to summary |
|---|---|
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception Overrides default org. Doc from org. Interception point before 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 an HTTP error or writing a custom response. Note special considerations apply for asynchronous
request processing. For more details see
The default implementation returns
| |
| setPathMatcher | back to summary |
|---|---|
| public void setPathMatcher(PathMatcher pathMatcher) Configure the PathMatcher to use to match URL paths with against include and exclude patterns. This is an advanced property that should be used only when a
customized By default this is Note Setting | |
PathPattern and the raw String pattern,
and uses the former when the cached path is PathContainer or the
latter otherwise. If the pattern cannot be parsed due to unsupported
syntax, then PathMatcher is used for all requests.
| Modifier and Type | Field and Description |
|---|---|
| private final PathPattern | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| private static PathPattern | |
| public static MappedInterceptor. | |
| public boolean |
| pathPattern | back to summary |
|---|---|
| private final PathPattern pathPattern
| |
| patternString | back to summary |
|---|---|
| private final String patternString | |
| PatternAdapter | back to summary |
|---|---|
| public PatternAdapter(String pattern, PathPatternParser parser) | |
| getPatternString | back to summary |
|---|---|
| public String getPatternString() | |
| initPathPattern | back to summary |
|---|---|
private static PathPattern initPathPattern(String pattern, PathPatternParser parser)
| |
| initPatterns | back to summary |
|---|---|
public static MappedInterceptor.
| |
| match | back to summary |
|---|---|
| public boolean match(Object path, boolean isPathContainer, PathMatcher pathMatcher) | |