类 WebRequestHandlerInterceptorAdapter
- java.lang.Object
- org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter
- 所有已实现的接口:
AsyncHandlerInterceptor
,HandlerInterceptor
public class WebRequestHandlerInterceptorAdapter extends Object implements AsyncHandlerInterceptor
Adapter that implements the Servlet HandlerInterceptor interface and wraps an underlying WebRequestInterceptor.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller
- 另请参阅:
WebRequestInterceptor
,HandlerInterceptor
构造器概要
构造器 构造器 说明 WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 ofpostHandle
andafterCompletion
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.
构造器详细资料
WebRequestHandlerInterceptorAdapter
public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.- 参数:
requestInterceptor
- the WebRequestInterceptor to wrap
方法详细资料
preHandle
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
从接口复制的说明: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 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
在接口中HandlerInterceptor
- 参数:
request
- current HTTP requestresponse
- current HTTP responsehandler
- 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.- 抛出:
Exception
- in case of errors
postHandle
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception
从接口复制的说明:HandlerInterceptor
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.
Note: special considerations apply for asynchronous request processing. For more details see
AsyncHandlerInterceptor
.The default implementation is empty.
- 指定者:
postHandle
在接口中HandlerInterceptor
- 参数:
request
- current HTTP requestresponse
- current HTTP responsehandler
- the handler (orHandlerMethod
) that started asynchronous execution, for type and/or instance examinationmodelAndView
- theModelAndView
that the handler returned (can also benull
)- 抛出:
Exception
- in case of errors
afterCompletion
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception
从接口复制的说明:HandlerInterceptor
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 returnedtrue
!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
在接口中HandlerInterceptor
- 参数:
request
- current HTTP requestresponse
- current HTTP responsehandler
- the handler (orHandlerMethod
) 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 resolver- 抛出:
Exception
- in case of errors
afterConcurrentHandlingStarted
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)
从接口复制的说明:AsyncHandlerInterceptor
Called instead ofpostHandle
andafterCompletion
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
在接口中AsyncHandlerInterceptor
- 参数:
request
- the current requestresponse
- the current responsehandler
- the handler (orHandlerMethod
) that started async execution, for type and/or instance examination