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)
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)
解决方案 »
- java编程
- 加载多个dwr配置文件问题
- struts2.x的推出能让所有的struts1.x的市场过渡到struts2.x吗
- 求助,如何获得找到我的页面使用的是什么搜索引擎??
- 如何提高struts的DynaActionForm的性能
- 我想学Java,各位如果是自学成才的能否帮忙提点建议。答者有分
- 用dom4j如何在XML文件中插入类似"<?xml-stylesheet type="text/xsl" href="demo.xsl"?>"这一行?
- 自定义标签问题
- 急问:用jdbc与sqlserver连接时出现的问题?
- hibernate.properties中怎么配置连接Sybase数据库啊?……
- tomcat部署项目去除工程名
- ssh怎么使用定时器?
public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
HttpServletRequest servletRequest,
HttpServletResponse serveltResponse) throws SQLException,
UnsupportedEncodingException {
......
return actionMapping.findForward("delete");}
deleteUser 改成 execute方法,你以为是struts2?
operate.do走的com.asm.forwardAction这个Action,action里有deleteUser这个方法
forwardAction继承DispatchAction
HttpServletRequest servletRequest,
HttpServletResponse serveltResponse) throws SQLException,
UnsupportedEncodingException把这个方法签名换成
public ActionForward deleteUser(ActionMapping actionMapping, ActionForm form,
HttpServletRequest servletRequest,
HttpServletResponse serveltResponse) throws Exception也就是抛的异常要和execute方法一样
试一下吧。
document.forms[0].method="post";
document.forms[0].submit();这不是有.do吗
<forward name="delete" path="/right.jsp"></forward>
</action>
配置文件的的parameter="deleteUser"
是你的项目不能编译了,你将tomcat下的class类文件反编译下就能看到action里没有这个deleteUser方法解决的方法只有重新开一个myeclipse就可以重新编译成功了 个人见解
在struts2中可以写任意方法名并实现类似execute的功能。