防止页面刷新重复提交表单,经过我在网上查资料,并且尝试,我采用了一种办法,利用token标签和tokenSession,只需要修改两个地方就可以,一个是修改jsp页面,另一个就是修改struts.xml文件。
1.struts.xml文件action部分
<action name="operatData" class="com.highgo.struts2.action.OperatData"
method="execute">
<result name="success">/index.jsp</result>
<result name="error">/error.jsp</result>
{<result name="invalid.token" type="freemarker">/index.jsp</result>
<interceptor-ref name="defaultStack">
<param name="workflow.excludeMethods">default</param>
</interceptor-ref>
<interceptor-ref name="tokenSession">
<param name="excludeMethods">default</param>
</interceptor-ref> }
</action>
{ }内的内容为需要添加的部分,用的时候要把{ }去掉
2.jsp页面
找到对应的action的页面,在表单下新增<s:token></s:token>
如下:
<form action="operatDataPost.action" method="post">
<s:token></s:token>
</form>