struts2防止表单重复提交



1、struts.xml文件action中配置重复提交表单拦截器

		<action name="login" class="loginAction">
			<result name="input">/login.jsp</result>
			<result name="success">/index.jsp</result>
			<!-- 重复提交表单时,跳转路径 -->
			<result name="invalid.token">/token.jsp</result>
			<!-- 重复提交表单拦截器 -->	
			<interceptor-ref name="token"></interceptor-ref>
			<!-- struts2默认拦截器 -->
			<interceptor-ref name="defaultStack"></interceptor-ref>
		</action>



2、前台代码添加在form表单里添加:<s:token></s:token>

		<s:form name="form1" action="login" method="POST">
			<s:token></s:token>
			<s:textfield name="user.userId" label="用户名" value=""
				style="width:200px;height:30px; line-height:20px;padding:5px;"></s:textfield>
			<s:password name="user.password" label="密 码" value=""
				style="width:200px;height:30px; line-height:20px;padding:5px;"></s:password>
			<s:submit value="提交" style="width:80px;height:25px;"></s:submit>
			<s:reset value="重置" style="width:80px;height:25px;"></s:reset>
		</s:form>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值