Top Description Fields Constructors Methods
org.springframework.web.servlet.handler

public Class WebRequestHandlerInterceptorAdapter

extends Object
implements AsyncHandlerInterceptor
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor
Imports
jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.context.request.AsyncWebRequestInterceptor, .WebRequestInterceptor, org.springframework.web.servlet.AsyncHandlerInterceptor, .ModelAndView

Adapter that implements the Servlet HandlerInterceptor interface and wraps an underlying WebRequestInterceptor.
Author
Juergen Hoeller
Since
2.0
See Also
org.springframework.web.context.request.WebRequestInterceptor, org.springframework.web.servlet.HandlerInterceptor

Field Summary

Modifier and TypeField and Description
private final WebRequestInterceptor

Constructor Summary

AccessConstructor and Description
public
WebRequestHandlerInterceptorAdapter(WebRequestInterceptor
the WebRequestInterceptor to wrap
requestInterceptor
)

Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.

Method Summary

Modifier and TypeMethod and Description
public void
afterCompletion(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
,
Object
the handler (or HandlerMethod) that started asynchronous execution, for type and/or instance examination
handler
,
Exception
any exception thrown on handler execution, if any; this does not include exceptions that have been handled through an exception resolver
ex
)

Overrides default org.springframework.web.servlet.HandlerInterceptor.afterCompletion.

Callback after completion of request processing, that is, after rendering the view.

public void
afterConcurrentHandlingStarted(HttpServletRequest
the current request
request
,
HttpServletResponse
the current response
response
,
Object
the handler (or HandlerMethod) that started async execution, for type and/or instance examination
handler
)

Overrides default org.springframework.web.servlet.AsyncHandlerInterceptor.afterConcurrentHandlingStarted.

Called instead of postHandle and afterCompletion when the handler is being executed concurrently.

public void
postHandle(HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
,
Object
the handler (or HandlerMethod) that started asynchronous execution, for type and/or instance examination
handler
,
ModelAndView
the ModelAndView that the handler returned (can also be null)
modelAndView
)

Overrides default org.springframework.web.servlet.HandlerInterceptor.postHandle.

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.springframework.web.servlet.HandlerInterceptor.preHandle.

Interception point before the execution of a handler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

requestInterceptorback to summary
private final WebRequestInterceptor requestInterceptor

Constructor Detail

WebRequestHandlerInterceptorAdapterback to summary
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)

Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.

Parameters
requestInterceptor:WebRequestInterceptor

the WebRequestInterceptor to wrap

Method Detail

afterCompletionback to summary
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception

Overrides default org.springframework.web.servlet.HandlerInterceptor.afterCompletion.

Doc from org.springframework.web.servlet.HandlerInterceptor.afterCompletion.

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.

Note

special considerations apply for asynchronous request processing. For more details see org.springframework.web.servlet.AsyncHandlerInterceptor.

The default implementation is empty.

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handler:Object

the handler (or HandlerMethod) that started asynchronous execution, for type and/or instance examination

ex:Exception

any exception thrown on handler execution, if any; this does not include exceptions that have been handled through an exception resolver

Annotations
@Override
Exceptions
Exception:
in case of errors
afterConcurrentHandlingStartedback to summary
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)

Overrides default org.springframework.web.servlet.AsyncHandlerInterceptor.afterConcurrentHandlingStarted.

Doc from org.springframework.web.servlet.AsyncHandlerInterceptor.afterConcurrentHandlingStarted.

Called instead of 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.

Parameters
request:HttpServletRequest

the current request

response:HttpServletResponse

the current response

handler:Object

the handler (or HandlerMethod) that started async execution, for type and/or instance examination

Annotations
@Override
postHandleback to summary
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception

Overrides default org.springframework.web.servlet.HandlerInterceptor.postHandle.

Doc from org.springframework.web.servlet.HandlerInterceptor.postHandle.

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 org.springframework.web.servlet.AsyncHandlerInterceptor.

The default implementation is empty.

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handler:Object

the handler (or HandlerMethod) that started asynchronous execution, for type and/or instance examination

modelAndView:ModelAndView

the ModelAndView that the handler returned (can also be null)

Annotations
@Override
Exceptions
Exception:
in case of errors
preHandleback to summary
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception

Overrides default org.springframework.web.servlet.HandlerInterceptor.preHandle.

Doc from org.springframework.web.servlet.HandlerInterceptor.preHandle.

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 org.springframework.web.servlet.AsyncHandlerInterceptor.

The default implementation returns true.

Parameters
request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

handler:Object

chosen handler to execute, for type and/or instance evaluation

Returns:boolean

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.

Annotations
@Override
Exceptions
Exception:
in case of errors