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