多个拦截器(假设有两个拦截器Interceptor1和Interceptor2,并且在配置文件中,Interceptor1拦截器配置在前)。
Interceptor1(preHandle)
---------return true--------------->
Interceptor2(preHandle)
--------------------------------->
HandlerAdapter(handle)
--------------------------------->
Interceptor2(postHandle)
------------------------------->
Interceptor1(postHandle)
------------------------------->
DispatcherServlet(render)
-------------------------------->
Interceptor2(afterCopmletion)
-------------------------------->
Interceptor1(afterCompletion)
当有多个拦截器同时工作时,它们的preHandle()方法会按照配置文件中拦截器的配置顺序 执行,而它们中的postHandle()方法和afterCompletion()方法则会按照配置顺序的反序执行。
多个拦截器的执行流程随笔
最新推荐文章于 2023-10-12 15:02:56 发布