to lovest317(韜(_少):多写一行什么?谢谢

解决方案 »

  1.   

    浏览器因为你的扩展文件名是shtml而取了缓存,想办法消掉浏览器的缓存。
      

  2.   

    to wuyg(平平):我的IE设置为不读取缓存,而且页面里也写了不读缓存,而且有数据重复提交问题,我觉得可能不是是缓存的问题吧?谢谢。
      

  3.   

    name="sysBean" scope="session"
    改为
     name="sysBean" scope="request"
    试试
    我觉得是因为这一句话保持了数据不变化
      

  4.   

    解决重复提交的几种方法:
    1 javascript ,设置一个变量,只允许提交一次。  
      <script language=\"javascript\"> 
       var checkSubmitFlg = false; 
       function checkSubmit() { 
       if (checkSubmitFlg == true) { 
       return false; 
       }
       checkSubmitFlg = true; 
       return true; 
       } 
       document.ondblclick = function docondblclick() { 
       window.event.returnValue = false; 
       } 
       document.onclick = function doconclick() { 
       if (checkSubmitFlg) { 
       window.event.returnValue = false; 
       } 
       } 
      </script> 
      <html:form action=\"myAction.do\" method=\"post\" onsubmit=\"return checkSubmit();\">   
      2 还是javascript,将提交按钮或者image置为disable   
       <html:form action=\"myAction.do\" method=\"post\" 
       onsubmit=\"getElById(\'submitInput\').disabled = true; return true;\"> 
       <html:image styleId=\"submitInput\" src=\"images/ok_b.gif\" border=\"0\" />  
       </html:form>   
      3 利用struts的同步令牌机制   
      利用同步令牌(Token)机制来解决Web应用中重复提交的问题,Struts也给出了一个参考实现。 
      基本原理:  
      服务器端在处理到达的请求之前,会将请求中包含的令牌值与保存在当前用户会话中的令牌值进行比较,看是否匹配。在处理完该请求后,且在答复发送给客户端之前,将会产生一个新的令牌,该令牌除传给客户端以外,也会将用户会话中保存的旧的令牌进行替换。这样如果用户回退到刚才的提交页面并再次提交的话,客户端传过来的令牌就和服务器端的令牌不一致,从而有效地防止了重复提交的发生。  
      if (isTokenValid(request, true)) { 
       // your code here 
       return mapping.findForward(\"success\"); 
      } else { 
       saveToken(request); 
       return mapping.findForward(\"submitagain\"); 
      }  
      Struts根据用户会话ID和当前系统时间来生成一个唯一(对于每个会话)令牌的,具体实现可以参考TokenProcessor类中的generateToken()方法。   
      1. //验证事务控制令牌,<html:form >会自动根据session中标识生成一个隐含input代表令牌,防止两次提交 
      2. 在action中:   
       //<input type=\"hidden\" name=\"org.apache.struts.taglib.html.TOKEN\" 
       // value=\"6aa35341f25184fd996c4c918255c3ae\"> 
       if (!isTokenValid(request)) 
       errors.add(ActionErrors.GLOBAL_ERROR, 
       new ActionError(\"error.transaction.token\")); 
       resetToken(request); //删除session中的令牌   
      3. action有这样的一个方法生成令牌   
       protected String generateToken(HttpServletRequest request) {   
       HttpSession session = request.getSession(); 
       try { 
       byte id[] = session.getId().getBytes(); 
       byte now[] = 
       new Long(System.currentTimeMillis()).toString().getBytes(); 
       MessageDigest md = MessageDigest.getInstance(\"MD5\"); 
       md.update(id); 
       md.update(now);
       return (toHex(md.digest())); 
       } catch (IllegalStateException e) {
       return (null);
       } catch (NoSuchAlgorithmException e) { 
       return (null); 
       } 
       }
      

  5.   

    把action改为   <forward name="success" path="/conf/main.shtml"/>
      

  6.   

    你象楼上那样转去main页好了。
    我以前习惯把查询和插入做成两个action,调用a.jsp这种显示页面都不是直接调,而是调用那个查询的action,查询成功后通过forward转到a.jsp去。插入的时候调用插入action,成功后forward到查询的那个action,这样就自动查询并在a.jsp页面显示了。
      

  7.   

    可以再写个List的方法,或者Action,这里做的事情就是再去取一下数据库里的数据,然后新记录添加成功后跳转到这个Action或者method上来,接着在这个新写的方法里执行完后跳转到A.jsp,另外一个页面就没必要写了
      

  8.   

    非常感谢各位朋友的帮助,通过把action改为   
    <forward name="success" path="/conf/main.shtml"/>
    后,列表可以正确显示.但是如果在列表列面上点右键刷新,会重复提交刚才数据,如何解决?谢谢
      

  9.   

    <forward name="success" path="/conf/main.shtml"/>改为
    <forward name="success" path="/conf/main.shtml" redirect="true"/>
    即可
      

  10.   

    让我头痛的问题,原来只需要小小的改动就可以解决.我要努力学习谢谢各位朋友.P.S. 没看明白esprit0318(遥远的AZA~~AZA~~FIGHTING......) "另外一个页面就没必要写了"的意思,我只写了两个页面呢,一个LIST,一个ADD.
      

  11.   

    把请求设置为重定向也是一种解决方案,只不过这种方法的缺点就是无法使用request传值到下一个页面,所以先确定是否要使用request传值,如果不需要,重定向redirect是一种不错的选择:
    <forward name="success" path="/conf/main.shtml" redirect="true"/>
      

  12.   

    因为你说form提交后到http://192.168.0.131/bget/conf/newType.shtml
    这不是一个新的页面么?
    可能是我理解错误了!
    谢谢你给了那么多分阿!^0^