Unable to instantiate Action, xxxAction, defined for ‘xxx‘ in namespace ‘/‘xxxAction解决方案
程序员文章站
2022-06-21 13:36:34
今天在写项目的时候,第一次使用Spring框架,发现确实好用,但是要配置的注解特别多,所以一不小心就会丢失一些核心注解。这不,我刚刚就遇到了如下问题,附上截图:具体报错如下:13:27:04.662 [http-nio-8989-exec-1] ERROR org.apache.struts2.dispatcher.Dispatcher - Exception occurred during processing request: Unable to instantiate Action, aucti...
今天在写项目的时候,第一次使用Spring框架,发现确实好用,但是要配置的注解特别多,所以一不小心就会丢失一些核心注解。这不,我刚刚就遇到了如下问题,附上截图:
具体报错如下:
13:27:04.662 [http-nio-8989-exec-1] ERROR org.apache.struts2.dispatcher.Dispatcher - Exception occurred during processing request: Unable to instantiate Action, auctionAction, defined for 'queryByPage' in namespace '/auction'auctionAction
com.opensymphony.xwork2.XWorkException: Unable to instantiate Action, auctionAction, defined for 'queryByPage' in namespace '/auction'auctionAction
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194) ~[xwork-core-2.3.16.jar:2.3.16]
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63) ~[struts2-core-2.3.16.jar:2.3.16]
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37) ~[struts2-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) ~[xwork-core-2.3.16.jar:2.3.16]
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552) [struts2-core-2.3.16.jar:2.3.16]
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) [struts2-core-2.3.16.jar:2.3.16]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) [struts2-core-2.3.16.jar:2.3.16]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.46]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.46]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.46]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.46]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528) [catalina.jar:8.5.46]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [catalina.jar:8.5.46]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.46]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) [catalina.jar:8.5.46]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.46]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [catalina.jar:8.5.46]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) [tomcat-coyote.jar:8.5.46]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.46]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810) [tomcat-coyote.jar:8.5.46]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-coyote.jar:8.5.46]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.46]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_231]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_231]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.46]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231]
Caused by: java.lang.ClassNotFoundException: auctionAction
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1360) ~[catalina.jar:8.5.46]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1182) ~[catalina.jar:8.5.46]
at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:128) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:233) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:153) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:171) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:141) ~[xwork-core-2.3.16.jar:2.3.16]
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:297) ~[xwork-core-2.3.16.jar:2.3.16]
... 27 more
话不多说,贴出解决方法:
注意此方法只针对采用spring注解开发模式!!!
1.检查struts.xml中的class属性,在spring框架中,此处应该为action类名的首字母小写
2.检查spring.xml或applicationContext.xml中是否开启了注解扫描,有如下语句代表开启:
<context:component-scan base-package="到哪个包里面去找注解"/>
例如我的包是:
<context:component-scan base-package="com.wyh"/>
检查完这些一般也都成功了!
本文地址:https://blog.csdn.net/qq_37608943/article/details/107358775
上一篇: jQuery 阻止事件冒泡