首页 > 其他 > 详细

struts2中token防止重复提交表单

时间:2015-07-13 02:04:11      阅读:318      评论:0      收藏:0      [点我收藏+]

struts2中token防止重复提交表单

?

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

蕃薯耀 2015年7月12日 11:52:32 星期日

http://fanshuyao.iteye.com/

?

?

第一步:在表单中加上<s:token></s:token>标签,这个需要在页面头引入struts的标签

<%@ taglib prefix="s" uri="/struts-tags" %>

?

例:

<s:form action="login" method="post" theme="simple">
		用户名:<s:textfield name="userName"></s:textfield><br/>
		密码:<s:password name="userPassword"></s:password><br/>
		
		<s:token></s:token>
		<input type="submit" value="登录" /><br/>
	</s:form>

?

?

第二步:在struts.xml文件中配置token,即配置重复提交跳转的页面及拦截器

<result name="invalid.token">token.jsp</result>
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>

?

例:

<package name="strutsTest" extends="struts-default">
    	<action name="login" class="com.struts2.action.LoginAction">
    		<result name="success">userIndex.jsp</result>
    		<result name="input">login.jsp</result>
    		<result name="invalid.token">token.jsp</result>
    		<interceptor-ref name="token"></interceptor-ref>
    		<interceptor-ref name="defaultStack"></interceptor-ref>
    	</action>
    </package>

?

?

?

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

蕃薯耀 2015年7月12日 11:52:32 星期日

http://fanshuyao.iteye.com/

struts2中token防止重复提交表单

原文:http://fanshuyao.iteye.com/blog/2226631

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!