日期:2014-05-18 浏览次数:20674 次
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<package name="test" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="a" class="ysgw/dave/myInterceptor/MyInterceptor"/>
</interceptors>
<default-action-ref name="test" />
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
<action name="test">
<interceptor-ref name="a"/>
<interceptor-ref name="defaultStack"/>
<result> /TestInterceptor.jsp</result>
</action>
</package>
package ysgw.dave.myInterceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class MyInterceptor extends AbstractInterceptor{
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
long startTime = System.nanoTime();
System.out.println("start time : " + startTime);
String result = invocation.invoke();
long endTime = System.nanoTime();
System.out.println("end time : " + endTime);
System.out.println("time : " + (endTime - startTime));
return result;
}
}