does not contain specified method (check logs)
2013-12-02 15:23
1266 查看
Action[/***] does not contain specified method (check logs)
今天利用SS1H框架整合做练习的时候,出现了一个Action中没有包含指定方法的Exception
异常信息:
想到了是自定义Action类中的方法调用时出现了问题。
从头到尾检查了N遍配置文件以及页面调用传参等代码块都未发现问题。。
许久后终于……
错误代码:
原来问题出在方法的参数中。这也怪自己偷鸡不成蚀把米。
本想偷懒一下,直接利用重写DispatchAction类中的execute方法,改一下名字后直接使用。
没想到,粗心选错,重写了Action类中的execute,结果可想而知。。。
解决方案:
顺便分享一下出现此异常的其他几种情况:
1、自定义Action类需要继承DispatchAction类。
2、方法参数ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response 顺序也需一致。
3、方法的访问修饰符设置为public、不是protected,更不是其他。
4、动态调用Action,在struts-config.xml中要配置Action的parameter参数,
参数是页面传值的参数,值与要执行Action中的方法名相同。
5、页面表单提交方式为post,否则也有可能出现这种异常。
今天利用SS1H框架整合做练习的时候,出现了一个Action中没有包含指定方法的Exception
异常信息:
2011-8-18 20:50:07 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet action threw exception java.lang.NoSuchMethodException: Action[/userAction] does not contain specified method (check logs) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:261) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170) at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:113) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)
想到了是自定义Action类中的方法调用时出现了问题。
从头到尾检查了N遍配置文件以及页面调用传参等代码块都未发现问题。。
许久后终于……
错误代码:
public ActionForward doQuery(ActionMapping mapping, ActionForm form, ServletRequest request, ServletResponse response) throws Exception { //内部实现略 }
原来问题出在方法的参数中。这也怪自己偷鸡不成蚀把米。
本想偷懒一下,直接利用重写DispatchAction类中的execute方法,改一下名字后直接使用。
没想到,粗心选错,重写了Action类中的execute,结果可想而知。。。
解决方案:
public ActionForward doQuery(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //内部实现略 }
顺便分享一下出现此异常的其他几种情况:
1、自定义Action类需要继承DispatchAction类。
2、方法参数ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response 顺序也需一致。
3、方法的访问修饰符设置为public、不是protected,更不是其他。
4、动态调用Action,在struts-config.xml中要配置Action的parameter参数,
参数是页面传值的参数,值与要执行Action中的方法名相同。
<action-mappings > <action path="/userAction" type="org.springframework.web.struts.DelegatingActionProxy" name="userForm" parameter="method" > <forward name="success" path="/index.jsp"></forward> <forward name="error" path="/error.jsp"></forward> </action> </action-mappings>
<html:form action="${pageContext.request.contextPath}/userAction.do?method=doQuery" method="post"> Name:<html:text property="user.fname"></html:text> Area:<html:text property="user.farea"></html:text> <html:submit value="Search Flowers"></html:submit> </html:form>
5、页面表单提交方式为post,否则也有可能出现这种异常。
相关文章推荐
- does not contain specified method (check logs)
- java.lang.NoSuchMethodException: Action[/role] does not contain specified method (check logs)紧急求救~
- 报错:Action[/statisticsManage] does not contain specified method (check logs)
- Action does not contain specified method (check logs) 错误
- Err:Action[/bbs] does not contain specified method
- does not contain specified method
- does not contain handler parameter named 'method' 异常
- WPF error: does not contain a static 'Main' method suitable for an entry point
- does not contain handler parameter named 'method'.错误
- 【原创】Mapped Statements collection does not contain value for DaoImpl.method
- does not contain handler parameter named 'method'
- does not contain handler parameter named 'method' 异常
- does not contain handler parameter named 'method'
- C#编译问题'System.Collections.Generic.IEnumerable' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument
- does not contain handler parameter named 'method'. This may be caused by whitespace in the label text
- does not contain method named
- WPF error: does not contain a static 'Main' method suitable for an entry point
- Dispatch时产生了这个异常:does not contain handler parameter named ‘method’ This may be caused by whitespace in the label text
- does not contain handler parameter named 'method'. This may be caused by whitespace in the label text错误
- does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.异常及其解决方案