JSP:
     JS方法中有
              if(confirm("确定要删除吗?")){
         document.forms[0].action="<%= request.getContextPath()%>/operate.do?method=deleteUser";
         document.forms[0].method="post";
         document.forms[0].submit();
     }
struts-config.xml:      <action path="/operate" type="com.asm.forwardAction" scope="request" parameter ="method" name="logForm">
          <forward name="delete" path="/right.jsp"></forward>
      </action>action中:
       public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
HttpServletRequest servletRequest,
HttpServletResponse serveltResponse) throws SQLException,
UnsupportedEncodingException {
......
return actionMapping.findForward("delete"); }为什么出下面错误:
- Action[/operate] does not contain method named 'deleteUser'
java.lang.NoSuchMethodException: com.asm.forwardAction.deleteUser(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- Unhandled Exception thrown: class java.lang.NoSuchMethodException
- Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodException: Action[/operate] does not contain specified method (check logs)

解决方案 »

  1.   

    action中:
      public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
    HttpServletRequest servletRequest,
    HttpServletResponse serveltResponse) throws SQLException,
    UnsupportedEncodingException {
    ......
    return actionMapping.findForward("delete");}
    deleteUser 改成 execute方法,你以为是struts2?
      

  2.   

    Struts1,action中还有其他方法,其它方法都可以正常运行,就是deleteUser这个方法不行
      

  3.   

    public class forwardAction extends DispatchAction {
      

  4.   

    deleteUser注意大小写,后面有没有加s
      

  5.   

    你的operate.do是走的哪个Action,在这个ACTION里有没有deleteUser()方法?
      

  6.   

    上面有代码,deleteUser没有错误。
    operate.do走的com.asm.forwardAction这个Action,action里有deleteUser这个方法
    forwardAction继承DispatchAction 
      

  7.   

    可能eclipse的问题,我以前也遇到过if else判断错误的情况,把电脑重启再开eclipse就对了
      

  8.   

    deleteUser方法的签名要和execute一样吧?public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
    HttpServletRequest servletRequest,
    HttpServletResponse serveltResponse) throws SQLException,
    UnsupportedEncodingException把这个方法签名换成
    public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
    HttpServletRequest servletRequest,
    HttpServletResponse serveltResponse) throws Exception也就是抛的异常要和execute方法一样
    试一下吧。
      

  9.   

    Eclipse重启了,tomcat也重启了,电脑也重启了还是不行
      

  10.   

    document.forms[0].action="<%= request.getContextPath()%>/operate.do?method=deleteUser";
    document.forms[0].method="post";
    document.forms[0].submit();这不是有.do吗
      

  11.   

    <%= request.getContextPath()%>要不把这个去了吧。
      

  12.   

    <%= request.getContextPath()%>去掉也不行
      

  13.   

     <action path="/operate" type="com.asm.forwardAction" scope="request" parameter ="method" name="logForm">
      <forward name="delete" path="/right.jsp"></forward>
      </action>
    配置文件的的parameter="deleteUser"
      

  14.   

    我碰到过
       是你的项目不能编译了,你将tomcat下的class类文件反编译下就能看到action里没有这个deleteUser方法解决的方法只有重新开一个myeclipse就可以重新编译成功了                           个人见解
      

  15.   

    很有可能是这个问题,如果是ide的话,经常出现这种问题。
      

  16.   

    在struts1的action类中式不允许自己定义功能类似于execute的方法的,把你得deleteUser方法名改成execute()应该就可以了。
    在struts2中可以写任意方法名并实现类似execute的功能。