public class

WebRequestHandlerInterceptorAdapter

extends Object
implements HandlerInterceptor
java.lang.Object
   ↳ org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter

Class Overview

Adapter that implements the Servlet HandlerInterceptor interface and wraps an underlying WebRequestInterceptor.

Summary

Public Constructors
WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
Public Methods
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
Callback after completion of request processing, that is, after rendering the view.
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.web.servlet.HandlerInterceptor

Public Constructors

public WebRequestHandlerInterceptorAdapter (WebRequestInterceptor requestInterceptor)

Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.

Parameters
requestInterceptor the WebRequestInterceptor to wrap

Public Methods

public void afterCompletion (HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)

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 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.

Parameters
request current HTTP request
response current HTTP response
handler chosen handler to execute, for type and/or instance examination
ex exception thrown on handler execution, if any
Throws
Exception

public void postHandle (HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)

Intercept the 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.

Parameters
request current HTTP request
response current HTTP response
handler chosen handler to execute, for type and/or instance examination
modelAndView the ModelAndView that the handler returned (can also be null)
Throws
Exception

public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler)

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.

Parameters
request current HTTP request
response current HTTP response
handler chosen handler to execute, for type and/or instance evaluation
Returns
  • 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.
Throws
Exception