在搭建SSH框架的时候,不明白struts2-spring-plugin-2.0.11.2.jar这个包是做什么用的,网上说是和spring搭配的包,所以我就导入了,可是tomcat启动时就报错,报错信息详见附近,这个包删除后就好了,希望高手能够解答struts2-spring-plugin-2.0.11.2.jar这个包到底是做什么用的?
看看整合的问题
http://blog.sina.com.cn/s/blog_4ed66efa0100cefj.html
http://it.wenda.sogou.com/question/32122932.html
http://www.bccn.net/Article/web/jsp/jszl/200810/8073.html
struts2与spring的整合。导入struts2-spring-plugin包,在web.xml中设置spring的监听器,
spring监听器对应的API类为:org.springframework.web.context.ContextLoaderListener。
struts2-spring-plugin包为我们将struts2的对象工厂设置为spring的IoC容器,其代码为:
<!-- 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.objectFactory定位为org.apache.struts2.spring.StrutsSpringObjectFactory
其余的工作就交给spring的IoC容器去做了。
另外:当我们需要增加spring的配置文件时,需要在web.xml中设定contextConfigLocation参数。代码如下:
contextConfigLocation
其他的spring配置文件名,用逗号隔开
你出的错是说没有导入Spring相关的包,而struts2-spring-plugin会需要它