当然不行了!
同时只能提交一个action。
一旦submit()了,就不会执行下面的代码了。为什么不把两个action要执行的动作放在一块呢?

解决方案 »

  1.   

    我的意思是
    按钮A
    document.frmPages.action = "/servlet1.do";
    document.frmPages.submit();按钮B
    document.frmPages.action = "/servlet2.do";
    document.frmPages.submit();一个jsp中的不同按钮可以提交2个servlet的阿
      

  2.   

    不行的。一个JSP页面只能有一个ACTIONFORM和相应的一个ACTION。
      

  3.   

    这个就好比重定向,当然没问题了,一个页面也可以对几个form的
      

  4.   

    yemao20() 你说的不对,一个action<->一个form,这个是没错,但jsp可以通过很多种方法触发.do的,这个“一个JSP页面只能有一个ACTIONFORM和相应的一个ACTION”完全是个错误观点
      

  5.   

    多按钮对应提交多form应该可以吧
      

  6.   

    能不能具体说说怎么配置,jsp怎么写阿
      

  7.   

    用按钮来控制提交到不同action肯定可以的。js 就行了。就不知道,能不能重复提交到不同的action.关注ing
      

  8.   

    jsp里面的javascript
      function doAction(operationName)
      {
        var actionUrl = "";
        var obj = document.getElementById("fittingsRetailInfoForm");
        obj.actionName.value = operationName;
        var ret;
        switch (operationName)
        {
            case "kensaku":
              obj.kensakuServerportId.value = obj.kensakuServerportId1.value;
              obj.kensakuServerportArea.value = obj.kensakuServerportArea1.value;
              obj.kensakuFittingsRetailFromId.value = obj.kensakuFittingsRetailFromId1.value;
              obj.kensakuFittingsRetailToId.value = obj.kensakuFittingsRetailToId1.value;
              obj.kensakuFittingsRetailFromDate.value = obj.kensakuFittingsRetailFromDate1.value;
              obj.kensakuFittingsRetailToDate.value = obj.kensakuFittingsRetailToDate1.value;
              obj.pageIndex.value = 1;
              actionUrl = "kensaku.do" ;
              ret = 1;
              break;
            case "add":
            case "edit":
              actionUrl = "modify.do" ;
              ret = 1;
              break;
            case "del":
              actionUrl = "delete.do" ;
              ret = confirm("确认要删除吗?");
              break;
            case "printview":
              actionUrl = "printview.do" ;
              ret = 1;
              break;
            case "monthprintview":
              actionUrl = "monthprintview.do" ;
              ret = 1;
              break;
            case "yearprintview":
              actionUrl = "yearprintview.do" ;
              ret = 1;
            break;
        }
        if (ret == 1) {
          //这个注意,是*.do,struts-config.xml里面的配置名
          obj.action = "/fittingsRetail/" + actionUrl;
          obj.submit();
        }下面掉用
    <input type="button" name="yearprintview" value="生成年报单"onClick="doAction('yearprintview')">
    struts-config.xml
        <action path="/fittingsRetail/kensaku"
                type="web.action.fittingsretail.FittingsRetailKensakuAction"
                name="fittingsRetailKensakuForm"
                scope="request"
                validate="false">
          <forward name="success" path="/fittingsretail/fittingsretailInfo.jsp"/>
          <forward name="error" path="/msg/Error_Message.jsp"/>
        </action>
        <action path="/fittingsRetail/kousin"
                type="web.action.fittingsretail.FittingsRetailKousinAction"
                name="fittingsRetailKousinForm"
                scope="session"
                validate="false">
          <forward name="success" path="/fittingsretail/fittingsretailInfo.jsp"/>
          <forward name="error" path="/msg/Error_Message.jsp"/>
        </action>
    以上是2个form关连2个action的
      

  9.   

    nouveau(路漫漫其修远兮) 你说的是一个do操作执行2个action?呵呵
    以前我都是<forward name="success" path="/XX/XX.do"/>这样把2个action关联起来的,不知道是不是这个意思
      

  10.   

    一个jsp中 可以有多个form的存在所以当然可以提交多个form 
    <html:form1>
      <html:button/>
    </html:form1>
    <html:form2>
       <html:button>
    </html:form2>
      

  11.   

    不行阿:
    JSP
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
    <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ page contentType="text/html; charset=GBK" %>
    <html:html>
    <head>
    <title>
    UntitledJsp1
    </title>
    <script language="javascript" >
    function Sua()
    {
         document.forms[0].method="post";
         document.forms[0].action = "/action1.do";
         document.forms[0].submit();}
    </script></head>
    <body>
    <h1>JBuilder Generated Struts JSP for ActionForm web13.ActionForm1</h1>
    <p>
    <html:form  action="/action1.do" method="POST"><a href='javaScript:Sua();'>aaa</a>
    <html:reset value ="Reset"/>
    </html:form>
    </body>
    </html:html>//struts-config
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
        <form-bean name="actionForm1" type="web13.ActionForm1" />
      </form-beans>
      <action-mappings>
        <action name="actionForm1" path="/action1" scope="request" type="web13.Action1" validate="false" />
      </action-mappings>
    </struts-config>
      

  12.   

    用<html:submit property="submit" value="Submit"/><br>提交是对的
      

  13.   

    to supersunyi(赖赖虫)     var obj = document.getElementById("fittingsRetailInfoForm");
        obj.actionName.value = operationName;请教fittingsRetailInfoForm是什么阿?
    operationName是action名?
      

  14.   

    to supersunyi(赖赖虫) 
    能不能把jsp贴出来看看
      

  15.   

    晕,有什么意义呢?你提交到一个action,再在里面判断条件不就OK了?
      

  16.   

    我找到问题了,是action.do的路径不对,用jbuildX新建的action在js里的路径和在<html:form 里是不同的如<html:form  action="/action2.do" method="POST">
    js里是var obj = document.getElementById("actionForm1");
         obj.action = "/WebModule1/action1.do";//多了"/WebModule1"
         obj.submit();
      

  17.   

    想象新浪的首页面,肯定有很多的form,很多的按钮,肯定不同的按钮触发了不同请求。
    也就是一个jsp页面,可以有很多form,很多form分别有对应的action事件。

    相对按钮来说,form是按钮的容器,action是按钮的事件。
    只要配置文件中,按钮触发的action事件,对应的formBean是按钮所在容器form的实例就可以了!
      

  18.   

    我已经调通了,可以一个jsp页面多个form,多个action的
      

  19.   

    我已经调通了,可以一个jsp页面多个form,多个action的