Struts2拦截器Interceptor执行顺序理解

invocation.invoke()方法是拦截器框架的实现核心,通过确定invocation.invoke()方法执行位置,来实现Action执行前后处理操作,在invocation.invoke()方法之前的代码将依据配置中拦截器顺序依次执行,直到走完拦截器后再执行invocation.invoke()方法调用Action,然后再依据配置中拦截器顺序反向执行invocation.invoke()方法后的代码,直到走完拦截器

如果我们有一个interceptor-stack的定义如下: 

Xml代码  
<interceptor-stack name="xaStack">   
  <interceptor-ref name="thisWillRunFirstInterceptor"/>   
  <interceptor-ref name="thisWillRunNextInterceptor"/>   
  <interceptor-ref name="followedByThisInterceptor"/>   
  <interceptor-ref name="thisWillRunLastInterceptor"/>   
</interceptor-stack>   


那么,整个执行的顺序大概像这样: 


原文地址:https://www.cnblogs.com/hujiapeng/p/5121610.html