public class MyInterceptor implements Interceptor { public void destroy() { } public void init() { } public String intercept(ActionInvocation invocation) throws Exception { System.out.println("+++++2+++++"); invocation.invoke(); System.out.println("=====2====="); return "sss"; } }
2.配置struts.xml
引用
<package name="default" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="test" class="com.struts.MyInterceptor"/>
</interceptors>
<action name="*_*" class="com.struts.{1}Action" method="{2}">
<result name="{2}">/{2}.jsp</result>
<interceptor-ref name="test"/>
<interceptor-ref name="defaultStack"/>
</action>
</package>
3.验证重复提交
配置struts.xml
引用
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="invalid.token"></interceptor-ref>
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="invalid.token"></interceptor-ref>
配置jsp
引用
<s:token></s:token>