您的位置:首页 > 其它

Unable to instantiate Action, xxxAction, defined for ‘xxx’ in namespace ‘/’xxxAction

2016-09-18 22:56 309 查看
             在做项目的时候遇到了一个问题,Unable to instantiate Action, xxxAction, defined for ‘xxx’ innamespace ‘/’xxxAction

             在控制台输出的日志中看到了问题,上网查后,在看看我的项目,才明白我将类的包名写错了,导致类实例化时找不到类。

一般出现这样的问题有两种情况。 包名写错,就无法在spring中来管理了,所以就出现这样

1、如果项目没有使用Spring,则struts.xml配置文件中,这个action的class属性的路径没有写完整,应该是包名.类名

2、如果项目使用了Spring,那就是applicationContext.xml里面没有为这个action定义bean。这样strus.xml中的对应action的class属性的值就是Spring配置文件中bean的id,比如:

applicationContext.xml

<span style="font-size:18px;"><bean id="adminAction" class="go.derek.action.AdminAction"
scope="prototype">
</bean></span>


struts.xml

<span style="font-size:18px;"><action name="admin" class="adminAction" method="execute">
<result>/admin.jsp</result>
</action></span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐