首页 > 其他 > 详细

防止表单重复提交(注入的方式)

时间:2015-10-14 21:46:20      阅读:156      评论:0      收藏:0      [点我收藏+]

1.jsp页面中

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

表单中加上<s:token></s:token>

 

2.在action中

@Results({
        @Result(name = "invalid.token", location ="url"),
})

@InterceptorRefs( {
    @InterceptorRef(value = "token",params={"includeMethods","actionmethod"}),  //actionmethod:方法名
    @InterceptorRef(value = "defaultStack")
})

 

原理:在提交表单时,随机生成session令牌存在session中,当表单重复提交时,生成新的令牌和存着的令牌匹配,如果匹配不一样,则禁止跳action。

防止表单重复提交(注入的方式)

原文:http://www.cnblogs.com/sizzy/p/4878859.html

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