难道只能用javascript?查,存,删,更,难道在x-work中写4个action配置??不能在写成一个action配置,然后在action中获得单击按钮的名称????

解决方案 »

  1.   

    <html>
    <script language="javascript">
    function submit()
    {
    if(document.getElementById('flag').value == ""){
    document.form.action ="find.action";
    }else{
    document.form.action = "delete.action";
    }
    }
    </script>
    <body>
    <ww:form name="form" namespace="/syz/action" action="find.action" method="POST">
         
    <tr><ww:hidden id="modifyflag" name="c.id"/>
    <tr>
    <input type="button" onclick="submit();" value="查询" /></th>
                    <input type="button" onclick="submit();" value="删除" /></th>
    </tr>
    </table>
    </ww:form>
    </body>
    </html>
    class Action(){
    public String find(){
    return success;
    }
    public String delete(){
    }
    }
    xwork.xml
    <xwork>
     <package name="syz" extends="default" namespace="/syz/action">
        <action name="find" class="action" method="find">
          <result name="success" type="dispatcher">/jsp/a.jsp</result>
        </action>
        <action name="delete" class="action" method="delete">
          <result name="success" type="dispatcher">/jsp/b.jsp</result>
        </action>
    </package>
    </xwork>其中c.id为,当你输入查询条件时,所查询出来的记录对应的id
      

  2.   

    <input type="submit"  value="查询" />
    <input type="submit"  value="删除" />public  class Action()
    {
      prvate String submit;
      public void setSubmit(String submit)
    {
      this.submit = submit;
    }
    public String execute(){if (submit.equals(查询))
    {
       ......
    }if (submit.equals(删除))
    {
    .....
    }
    return success;
    }
    }
      

  3.   

    呵呵,我说的就是除了这个方法之外,有没有办法在同一个action中进行选择处理.
    比如这样:
     if(this.hasKey("delete")){
       delete();
    }if(this.hasKey("save")){
       save();
    }
    这样呢??
      

  4.   

    呵呵,谢谢啊CAYU(中原) 兄,搞定了!