可以一个form对应多个action,但是传过来的变量都要放在form中不太好管理,主要是看你怎么使用

解决方案 »

  1.   

    一个action使用多个form 肯定不行,而且为什么要这么做呢,同时执行2个程序吗?
      

  2.   

    难道你想把一个页面分成多个FORM?但是你这N个FORM应该是不一样的数据,这么会都提交到同一个ACTION处理呢。
      

  3.   

    你说的多个form应该是不同的累吧。这要看数据流和业务了,比如:有很多画面包含与业务关系不大的项目相同,可以写成一个form
      

  4.   

    我公司就是这么做的,使用多个form对应一个action,
    关键是配置文件的写法!
    同事告诉我这样配置:<form-bean name="aform"                type="com.safety.struts.form.AForm" />
    <form-bean name="bform"                type="com.safety.struts.form.BForm" />
    <action
          attribute="aform"
          name="aform"
          path="/A"
          parameter="hMethod"
          scope="request"
          type="com.safety.struts.action.AAction"   
          validate="false">      <forward name="initDirect"   path="/experience/experience_main.jsp" />
              </action>
        <action
          attribute="bForm"
          name="bForm"
          path="/B"
          parameter="hMethod"
          scope="request"
          type="com.safety.struts.action.AAction"   
          validate="false">
           <forward name="editArchivesDirect"   path="/archives/archives_edit.jsp" />
        </action>就是配置多个 <action> type属性是同一个类,
      

  5.   

    一个Action可以对应多个Form, 其实这和Form没关系, 确切的说是只和传入的属性名有关系.
    只取自己感兴趣的属性就好了!
    当然多个Form要有相似性!
      

  6.   

    MappingDispatchAction也可以做到一个action对应多个form
      

  7.   

    怎么不等提交到action中啊路径老是错误
    <script type="text/javascript">
         function tea(){
        
        
         document.form1.action="userRegister.do?method=RegisterZhanghao";
         document.form1.submit();
        
         }
        
        </script>
      
      </head>
         <form action="userRegister.do?method=PutLeaveWordRubbish" method="post" name="form1" id="form1">
         
         <input type="buttion" onclick="tea()" value="提交">
       
       </form>
      

  8.   

    你同时提交给Action肯定不行了。把<from >里的Action去掉就行了。