struts2使用拦截器(自定义拦截器)时出现以下问题:[color=red]当不使用拦截器时页面正常跳转[/color],当使用拦截器后页面总是跳转到/error.jsp页面,不管输入的是正确还是错误!请各位解答是怎么回事,谢谢了!
附相关代码:
struts.xml:
[code="java"]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
/success.jsp
/error.jsp
[/code]
MyInterceptor.java:
[code="java"]
package interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class MyInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
long start = System.currentTimeMillis();
String res = invocation.invoke();
long end = System.currentTimeMillis();
System.out.println("执行"+ invocation.getClass().getName()+"耗时"+(end-start)+"ms");
return res;
}
}
[/code]