为了解决表单的重复提交问题,我们选用如下代码方式:
<ww:form method= "post ">
<ww:token/>
</ww:form>
在 <ation> 配置中增加
<result name= "invalid.token "> /error.jsp </result>
<interceptor-ref name= "params "> </interceptor-ref>
<interceptor-ref name= "token "> </interceptor-ref>
但是在我的程序中这种办法就是不好用,经过实验发现如下配置方式也是比较好用的:
<ww:form method= "post ">
<ww:token/>
</ww:form>
在 <ation> 配置中增加
<interceptor-ref name="token"/>
<interceptor-ref name="basicStack"/>
<result name= "invalid.token "> /error.jsp </result>
大家可以试试。
本文介绍了一种防止Web表单重复提交的有效方法。通过使用Struts2提供的<ww:token>标签并配置拦截器,可以有效避免因刷新等原因造成的表单重复提交问题。文章给出了具体的配置示例。
2492

被折叠的 条评论
为什么被折叠?



