Struts2 使用 Spring 的 IOC

在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>

你可能感兴趣的:(spring,tomcat,Web,struts,IOC)