不能初始化action Unable to instantiate Action, homePageAction

本文介绍了一个关于Struts2框架中遇到的内部错误问题,详细分析了异常原因,并给出了具体的解决方案,即为受影响的Action类添加@Controller和@Scope(prototype)注解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

Unable to instantiate Action, homePageAction,  defined for 'HomePageAction' in namespace '/ztg'homePageAction
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

root cause

java.lang.ClassNotFoundException: homePageAction
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
	com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
	com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:108)
	com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:233)
	com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:153)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
	com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:121)
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:297)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

解决原因是 action忘记加 
@Controller
@Scope("prototype")
所以不能初始化
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值