在Tomcat启动时,产生如下异常:
严重: Exception starting filter struts2
Cannot locate the chosen ObjectFactory implementation: spring
struts.properties 文件设置如下:
struts.objectFactory = spring
原因:
缺少 struts2-spring-plugin-2.0.11.1.jar 包
Struts2 中使用 Spring 的 IOC 应加入以下 jar 包
spring-core-2.0.5.jar
spring-beans-2.0.5.jar
spring-context-2.0.5.jar
spring-web-2.0.5.jar
struts2-spring-plugin-2.0.11.1.jar
在 /WEB-INF/web.xml 文件中加入Spring的 ContextLoaderListener 监听器,方便Spring与Web容器交互。
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>