1、struts.xml文件action中配置重複提交表單攔截器
<action name="login" class="loginAction">
<result name="input">/login.jsp</result>
<result name="success">/index.jsp</result>
<!-- 重複提交表單時,跳轉路徑 -->
<result name="invalid.token">/token.jsp</result>
<!-- 重複提交表單攔截器 -->
<interceptor-ref name="token"></interceptor-ref>
<!-- struts2默認攔截器 -->
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>
2、前臺代碼添加在form表單裏添加:<s:token></s:token>
<s:form name="form1" action="login" method="POST">
<s:token></s:token>
<s:textfield name="user.userId" label="用戶名" value=""
style="width:200px;height:30px; line-height:20px;padding:5px;"></s:textfield>
<s:password name="user.password" label="密 碼" value=""
style="width:200px;height:30px; line-height:20px;padding:5px;"></s:password>
<s:submit value="提交" style="width:80px;height:25px;"></s:submit>
<s:reset value="重置" style="width:80px;height:25px;"></s:reset>
</s:form>