码迷,mamicode.com
首页 > 其他好文 > 详细

struts1与struts2的防止表单重复提交

时间:2014-08-08 15:40:56      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   

struts1的防止表单重复提交

一、方法:利用令牌来解决页面重复提交的问题

二、步骤

  2.1  Action中需要添加以下代码

    

public ActionForward entry(ActionMapping mapping, ActionForm form,  
           HttpServletRequestrequest, HttpServletResponse response)  
           throws Exception {  
       saveToken(request);  
       return mapping.findForward("showAll");  
    }  
    public ActionForward  update(ActionMapping mapping, ActionForm form,  
           HttpServletRequestrequest, HttpServletResponse response)  
           throws Exception {  
       if (isTokenValid(request, true)) {  
           UserForm actionForm=(UserForm)form;  
           .................
           return mapping.findForward("success");  
       }else{  
           saveToken(request);  
           return mapping.findForward("error");  
       }  
        
    }      

  2.2 jsp页面必须用struts1标签表单

 

<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html" %>
<html:form action="User" method="post">
‘‘‘‘‘‘‘‘‘‘‘‘‘
</html:form>

 

struts1与struts2的防止表单重复提交,布布扣,bubuko.com

struts1与struts2的防止表单重复提交

标签:style   blog   http   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/tombsky/p/3899247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!