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>