struts2--使用<s:token></s:token>标签防止重复提交
取个小例子:
这是网页:
<body> <s:actionerror/> <s:form action="LoginAction" method="post"> <s:token></s:token> <s:textfield name="produ" label="预定产品的编号" /> <s:textfield name="onum" label="预定数量" /> <s:submit value="提交"></s:submit> </s:form> </body>
这是struts-xml配置文件:
1 <action name="LoginAction" class="sedion.xq.action.LoginAction"> 2 3 4 5 <interceptor-ref name="token"></interceptor-ref> 6 7 8 9 <interceptor-ref name="defaultStack"></interceptor-ref> 10 11 12 13 <result> 14 15 16 17 /dakjfhkah.jsp 18 19 20 21 </result> 22 23 <result name="invalid.token">/index.jsp</result> 24 25 26 27 </action> 28 29 30 or 31 32 33 <action name="LoginAction" class="sedion.xq.action.LoginAction"> 34 35 36 <interceptor-ref name="tokenSession"></interceptor-ref> 37 38 39 <interceptor-ref name="defaultStack"></interceptor-ref> 40 41 42 <result> 43 44 45 /dakjfhkah.jsp 46 47 48 </result> 49 50 51 52 </action>
【不懂可以发帖 版主一直在。】