Caused by: java.lang.NullPointerException at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209)
大致是不能得到struts2的action管理对象,使用三大框架继承时,使用struts2-spring-plugin-2.2.1.jar这个插件时,spring ioc容器会代为管理struts2的action对象 原因:
1, 没用使用到这个包
2,使用这个包后没有在web.xml中配置 需加上监听
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
3,其他包冲突 博主就是因为 包冲突 以org.springframework.web.context开头的包有两个,删掉小的就好了
补充, 如何删掉myEclipse中的包,方法:先删掉引用(包名后带路径) ,然后在删除包 不然会报错
本文解决了一个关于Struts2与Spring框架整合时出现的NullPointerException异常问题。问题的根源在于Spring IOC容器未能正确管理Struts2的Action对象。解决方法包括确保引入了正确的依赖包、在web.xml中配置Spring的监听器以及解决可能存在的类库冲突。
241

被折叠的 条评论
为什么被折叠?



