在java项目中,出现下面的错误是什么原因?我是用SSH框架做的,请大家帮帮忙!不胜感激!

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.bbs.controller.LoginAction] for bean with name 'loginAction' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: com/opensymphony/xwork2/Action

看提示,你用的是Struts2,你的loginAction的配置有问题,没有生效所以报错了。检查你的struts的配置文件。追问

追答

struts.xml中,把action的配置class="loginAction",修改为class="com.bbs.controller.LoginAction",就对了。

如果class="loginAction",也可以,但需要在LoginAction中加注解声明为单例,出于性能,这种方式不建议使用。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-11-26
相应的依赖包未引用或者包冲突了
第2个回答  2014-11-26
缺少一个包吧
相似回答