struts2学习dem007_token令牌防止重复提交
2012-10-11 21:57
323 查看
第一种:将其显示到一个错误的页面 -- --- ----论坛网站用的较多
1.》jsp页面:
创建个提交的jsp页面,加上一个<s:token></s:token>即可
如:
<form action="<%=basePath%>/login" method="post">
用户名:<input type="text" name="username"/><br/>
密 码:<input type="password" name="password"/><br/>
<s:token></s:token>
<input type="submit" value="登 录"/>
</form>
2》Action页面:
就写个验证登陆的:
3》struts.xml页面:
在<action>里面加上过滤器:
<result name="success">/loginSuc.jsp</result>
<result name="invalid.token">/repeatSubmitError.jsp</result>//将其重复提交时转向的页面
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
Ok-------------------------------------
验证:当你登录到成功页面时,再次刷新会提交到重复提交的页面!
第二种:利用tokenSession。就是发现重复提交,则为用户返回result的Success结果。还是返回到登录成功的页面,只不过后台并不是你想象的那样成功,他只访问Action一次,其余几次都被拦截器拦截。
(常用于购物网站)
1》jsp页面同上
2》action页面同上
3》struts.xml页面
<result name="success">/loginSuc.jsp</result>
<result name="invalid.token">/loginSubmitError.jsp</result>
<interceptor-ref name="tokenSession"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
这一直是成功页面
1.》jsp页面:
创建个提交的jsp页面,加上一个<s:token></s:token>即可
如:
<form action="<%=basePath%>/login" method="post">
用户名:<input type="text" name="username"/><br/>
密 码:<input type="password" name="password"/><br/>
<s:token></s:token>
<input type="submit" value="登 录"/>
</form>
2》Action页面:
就写个验证登陆的:
3》struts.xml页面:
在<action>里面加上过滤器:
<result name="success">/loginSuc.jsp</result>
<result name="invalid.token">/repeatSubmitError.jsp</result>//将其重复提交时转向的页面
<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
Ok-------------------------------------
验证:当你登录到成功页面时,再次刷新会提交到重复提交的页面!
第二种:利用tokenSession。就是发现重复提交,则为用户返回result的Success结果。还是返回到登录成功的页面,只不过后台并不是你想象的那样成功,他只访问Action一次,其余几次都被拦截器拦截。
(常用于购物网站)
1》jsp页面同上
2》action页面同上
3》struts.xml页面
<result name="success">/loginSuc.jsp</result>
<result name="invalid.token">/loginSubmitError.jsp</result>
<interceptor-ref name="tokenSession"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
这一直是成功页面
相关文章推荐
- Struts2学习10--防止表单的重复提交token标签和tokenSession
- Struts2学习10--防止表单的重复提交token标签和tokenSession
- Struts2学习笔记之<s:token/>防止表单重复提交
- Struts2学习笔记之<s:token/>防止表单重复提交
- 防止表单重复提交 PHP Token(令牌)设计
- Struts2_防止重复提交的token拦截器
- JavaWeb 如何防止表单重复提交 - 使用Token,令牌
- [原创]java WEB学习笔记73:Struts2 学习之路-- strut2中防止表单重复提交
- Struts2标签<s:token />防止表单重复提交
- java struts2入门学习--防止表单重复提交.OGNL语言学习
- Struts2中使用<s:token>防止表单重复提交
- Struts2 中使用token标签防止刷新和后退进行重复提交
- struts利用Token(令牌)防止用户重复提交
- 如何防止表单重复提交(token令牌)
- Struts2利用token和tokenSession拦截器防止重复提交
- struts2防止表单重复提交(s:token)
- Struts2 <s:token>防止表单重复提交 %{}
- struts利用Token(令牌)防止用户重复提交
- Struts2用token防止表单数据重复提交
- 【学习笔记】Web开发中防止页面刷新后表单重复提交,表单Token设置示例