为什么拦截器 actionInvocation.invoke()之后 不能通过return跳转,该怎么解决
为什么拦截器 actionInvocation.invoke()之后 不能通过return跳转
这个自定义拦截器为什么不能返回error页面?
struts.xml 有设置全局result
<global-results>
<result name="error">/pages/error.jsp</result>
</global-results>
这样就可以成功返回error页面。
请问为什么?谢谢!
------解决方案--------------------
actionInvocation.invoke() 就是通知struts2接着干下面的事情
比如 调用下一个拦截器 或 执行下一个Action
就等于退出了你自己编写的这个interceptor了.
- Java code
public String intercept(ActionInvocation actionInvocation) throws Exception { System.out.println("before"); actionInvocation.invoke(); System.out.println("after"); return "error"; }
这个自定义拦截器为什么不能返回error页面?
struts.xml 有设置全局result
<global-results>
<result name="error">/pages/error.jsp</result>
</global-results>
- Java code
public String intercept(ActionInvocation actionInvocation) throws Exception { System.out.println("before"); return "error"; actionInvocation.invoke(); System.out.println("after"); }
这样就可以成功返回error页面。
请问为什么?谢谢!
------解决方案--------------------
actionInvocation.invoke() 就是通知struts2接着干下面的事情
比如 调用下一个拦截器 或 执行下一个Action
就等于退出了你自己编写的这个interceptor了.