在同一个表单中有个SUBMIT按钮,我想单击两个不同的按钮执行不同的操作,不知道应该怎么处理,我想用DynaAction和DynaActionForm,但不太清楚怎么使用,总提示没有getter mothed,可我在FORM中写了这个方法了???请各位帮忙!!!

解决方案 »

  1.   

    你不清楚这个问题说明你对HTML中这个问题还不是很清楚,和struts无关。你自己先用HTML写一个
    <form action="2.html" method="get">
    <input type="submit" name="sub" value="1"/>
    <input type="submit" name="sub" value="2"/>
    </form>
    提交以后你观察你地址拦里面的值如:
    2.html?name=name&sub=2发现了什么?你点哪一个提交按纽那么sub的值就是你点那个按纽的值。知道了这个,那么你就可以猜想struts的Look和ispatchAction是怎么实现的了,无非也就是把这个值读出来和某个方法建立一个映射关系
      

  2.   

    用两个button不就行了,每个button都有一个onclick事件调用一个javascript函数,在函数里进行提交。
    function sub1(){
      document.all.form.action="";
      document.all.form.submit();
    }
    function sub2(){
      document.all.form.action="";
      document.all.form.submit();
    }
      

  3.   

    每个button都有一个onclick事件调用一个javascript函数还有 任何一个图片或A练级都可以用 onclick事件调用一个javascript函数
      

  4.   

    HTTP Status 400 - Request[/login/Login] does not contain handler parameter named action提示这个错误是什么原因啊?<html:submit property="action" styleClass="login_button"><bean:message key="login.submit.login"/></html:submit>
    <html:submit property="action" styleClass="login_button"><bean:message key="login.submit.reg"/></html:submit>struts-config.xml<action-mappings >
        <action
          attribute="loginForm"
          input="/login/login.jsp"
          name="loginForm"
          path="/login/Login"
          parameter="action"
          scope="request"
          type="l.actions.LoginAction" />  </action-mappings>
      

  5.   

    原因找到了,login.submit.login这个是定义在资源文件中的,如果这样写login.submit.login=登录 就会出现上面的错误,如果不用中文就没事,怎么解决呢?
      

  6.   

    资源文件里面不是直接写中文的,必须是要native2ascii.exe转化后才可以
      

  7.   

    在eclipse里面的myeclipse有个插件,直接写中文,只要一保存就已转换了...
    大家下来试试..很有用的.
      

  8.   

    问题解决了,只要在ActionForm的reset方法中加入下面的语句就可以了try { 
    request.setCharacterEncoding("GB2312"); 
    }catch (UnsupportedEncodingException ex) { 
    System.out.println(ex.getMessage()); 
    }