does not contain specified method (check logs)

原创 2013年12月02日 15:23:21
Action[/***] does not contain specified method (check logs)

今天利用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的时候一直报 java.lang.NoSuchMethodException: Action[/btnQryMsgResultAction] does not contain spe...

eclipse解决editor does not contain a main type的方法

写在前面的话:我的也出现这个问题,但是解决方法和转发的内容不太一样,原理一样,我是右击src--build path--use as source folder,估计以前是删除了工程中的部分东西,如果...

iOS报错:does not contain bitcode Xcode7

在真机试调的过程中,运行项目,发现报错: ' does not contain bitcode. You must rebuild it with bitcode enabled (Xco...

mybatis报错(三)报错Result Maps collection does not contain value for java.lang.Integer解决方法

项目报错信息: [WARN ] 2016-03-25 13:03:23,955 - org.springframework.remoting.support.RemoteInvocationTrace...

Mapped Statements collection does not contain value for Addressbook.getByIds

严重: Servlet.service() for servlet [springmvc] in context with path [/testcs_dn-web] threw exception ...

关于 “does not contain bitcode.”的错误解决办法

Xcode7运行项目时出现了如下的错误:does not contain bitcode. You must rebuild it with bitcode enabled (Xcode settin...

Mapped Statements collection does not contain value for WaitMissionMapper.updateWait

1、错误描述### Error updating database. Cause: java.lang.IllegalArgumentException: Mapped Statements col...

Mapped Statements collection does not contain value for com.xinrui.micromessage.bean.Message.insert

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Persiste...
  • lzc4869
  • lzc4869
  • 2016年03月20日 20:38
  • 700

xcodebuild does not contain a scheme named

执行如下命令: xcodebuild -workspace $WORKSPACE_PATH -scheme ${SCHEME_NAME} -sdk iphoneos archive -confi...
  • hphua
  • hphua
  • 2016年11月30日 21:42
  • 1491
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:does not contain specified method (check logs)
举报原因:
原因补充:

(最多只允许输入30个字)