strtus2 中使用<s:token/>可以防止表单重复提交。
struts.xml:
<action name="OGNLTestAction" class="com.wyx.dmi.OGNLTestAction"> <interceptor-ref name="defaultStack"/> <interceptor-ref name="token"/> <result name="invalid.token">message.jsp</result> <result>/ognlTest.jsp</result> </action>
message.jsp页面为出现重复提交,跳转到得页面。
jsp页面中:
<a href="OGNLTestAction">t>>>OGNL--TEST</a><br>
<s:form name="myform" method="post" action="OGNLTestAction"namespace="/">
<s:token/>
<s:submit value="提交"></s:submit>
</s:form>
在做测试的时候有时候报错:
Form action defaulting to 'action' attribute's literal value
该错误是<s:form>标签写的有问题