public class WebRequestHandlerInterceptorAdapter extends Object implements AsyncHandlerInterceptor
WebRequestInterceptor
,
HandlerInterceptor
Constructor and Description |
---|
WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterCompletion(HttpServletRequest request,
HttpServletResponse response,
Object handler,
Exception ex)
Callback after completion of request processing, that is, after rendering
the view.
|
void |
afterConcurrentHandlingStarted(HttpServletRequest request,
HttpServletResponse response,
Object handler)
Called instead of
postHandle and afterCompletion
when the handler is being executed concurrently. |
void |
postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView)
Intercept the execution of a handler.
|
boolean |
preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler)
Intercept the execution of a handler.
|
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
requestInterceptor
- the WebRequestInterceptor to wrappublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
HandlerInterceptor
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
AsyncHandlerInterceptor
.
The default implementation returns true
.
preHandle
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- chosen handler to execute, for type and/or instance evaluationtrue
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.Exception
- in case of errorspublic void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception
HandlerInterceptor
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
AsyncHandlerInterceptor
.
The default implementation is empty.
postHandle
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- the handler (or HandlerMethod
) that started asynchronous
execution, for type and/or instance examinationmodelAndView
- the ModelAndView
that the handler returned
(can also be null
)Exception
- in case of errorspublic void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception
HandlerInterceptor
Note: Will only be called if this interceptor's preHandle
method has successfully completed and returned true
!
As with the postHandle
method, the method will be invoked on each
interceptor in the chain in reverse order, so the first interceptor will be
the last to be invoked.
Note: special considerations apply for asynchronous
request processing. For more details see
AsyncHandlerInterceptor
.
The default implementation is empty.
afterCompletion
in interface HandlerInterceptor
request
- current HTTP requestresponse
- current HTTP responsehandler
- the handler (or HandlerMethod
) that started asynchronous
execution, for type and/or instance examinationex
- any exception thrown on handler execution, if any; this does not
include exceptions that have been handled through an exception resolverException
- in case of errorspublic void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)
AsyncHandlerInterceptor
postHandle
and afterCompletion
when the handler is being executed concurrently.
Implementations may use the provided request and response but should avoid modifying them in ways that would conflict with the concurrent execution of the handler. A typical use of this method would be to clean up thread-local variables.
afterConcurrentHandlingStarted
in interface AsyncHandlerInterceptor
request
- the current requestresponse
- the current responsehandler
- the handler (or HandlerMethod
) that started async
execution, for type and/or instance examination