Posted on 2010-09-08 17:15
瘋狂 閱讀(8806)
評論(0) 編輯 收藏 所屬分類:
java 、
questions_hander 、
questions 、
spring
在不使用spring。單獨使用struts是報錯:
嚴重: Exception starting filter struts2
java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:190)
。。。
原因是多了一個struts2-spring-plugin-X.jar包,
此包是struts的spring的插件:
打開struts2-spring-plugin-X.jar看一下struts-plugin.xml內容:
<struts>
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />
<!-- Make the Spring object factory the automatic default -->
<constant name="struts.objectFactory" value="spring" />
<package name="spring-default">
<interceptors>
<interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
<interceptor name="sessionAutowiring" class="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor"/>
</interceptors>
</package>
</struts>
請大家關注紅色部分:
<!-- Make the Spring object factory the automatic default -->意思是:會將Spring object factory 設置為默認。也就是說我們不配置struts.objectFactory=spring 但是只要這個包在classpath下就等于設置了struts.objectFactory=spring 。
解決辦法,去掉此包即可.