weixin_42356868 2010-02-02 23:29
浏览 278
已采纳

Struts Problem Report Unable to instantiate Action

[code="java"][/code]

我用struts2 做的毕设,
我按网上所说,不要在成员变量或者是构造方法里调用ActionContext,而把它放在其它方法里.
于是我把ServletActionContext放到getters中,
问题依然存在,不知道还有什么原因会导致该问题的呢?

struts.xml配置:




/common/page/success.jsp
/common/page/error.jsp
/common/page/none.jsp

页面上的链接:




/s:url

checkAction部分代码:

public class CheckAtion extends ActionSupport{

private static final long serialVersionUID = 1L;
private Long enterNumber;
private String enterStatus;

public Long getEnterNumber() {
if(enterNumber == null ) {
enterNumber = Long.parseLong((String)(ServletActionContext.getRequest().getParameter("enterNumber")));
}
return enterNumber;
}

public String getEnterStatus() {
if(enterStatus.trim() == null) {
enterStatus = (String)(ServletActionContext.getRequest().getParameter("enterStatus"));
enterStatus = ConvertCharacter.convertCh(enterStatus);
}
return enterStatus;
}

public String execute() {
GodownService checkService = new GodownService();

if(getEnterNumber() != null && getEnterStatus() != null) {
if(checkService.setEnterStatus(enterNumber, enterStatus)) {
System.out.println("at CheckAction.execute()setEnterStatus success");
return SUCCESS;
}
else {
System.out.println("at CheckAction.execute() setEnterStatus fail");
return ERROR;
}
}else {
System.out.println("at CheckAction.execute()\n" +
"enterNumber == null && enterStatus.trim() == null");
return INPUT;
}

}

报错:
Struts Problem Report
Struts has detected an unhandled exception:

Messages: MPDMS.view.storeManage.CheckAction
Unable to instantiate Action, MPDMS.view.storeManage.CheckAction, defined for 'checkAction' in namespace ''MPDMS.view.storeManage.CheckAction

File: org/apache/catalina/loader/WebappClassLoader.java
Line number: 1,387


Stacktraces
Unable to instantiate Action, MPDMS.view.storeManage.CheckAction, defined for 'checkAction' in namespace ''MPDMS.view.storeManage.CheckAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:306)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)

java.lang.ClassNotFoundException: MPDMS.view.storeManage.CheckAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:96)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:206)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:128)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:287)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:387)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:458)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Unknown Source)


You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:

struts.devMode=false

in your WEB-INF/classes/struts.properties file.

  • 写回答

1条回答 默认 最新

  • unika_ly12 2010-02-03 09:14
    关注

    加个namespace名称试试,另外看看你包名写的对不对

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 paddle库安装时报错提示需要安装common、dual等库,安装了上面的库以后还是显示报错未安装,要怎么办呀?
  • ¥20 找能定制Python脚本的
  • ¥15 odoo17的分包重新供应路线如何设置?可从销售订单中实时直接触发采购订单或相关单据
  • ¥15 用C语言怎么判断字符串的输入是否符合设定?
  • ¥15 通信专业本科生论文选这两个哪个方向好研究呀
  • ¥50 我在一个购物网站的排队系统排队,这个排队到号后重新定向到目标网站进行购物,但是有技术牛通过技术方法直接跳过排队系统进入目标网址购物,有没有什么软件或者脚本可以用
  • ¥15 ios可以实现ymodem-1k协议 1024字节传输吗?
  • ¥300 寻抓云闪付tn组成网页付款链接
  • ¥15 请问Ubuntu要怎么安装chrome呀?
  • ¥15 视频编码 十六进制问题