一般情况下,做ssh组合时,spring是通过web.xml加载,这样使用xfire就没有问题了。但有时需要用struts加载spring(通过struts-config.xml文件中的 plugin加载spring),这时将xfire添加进来,会发现service没有被加载。
xfire的配置文件是通过web.xml加载的,而这里spring通过struts加载,两实例不能共享。
解决:
1: struts里,plugin这样写, value=""
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="" />
</plug-in>
2. web.xml加载
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext-*.xml
classpath:org/codehaus/xfire/spring/xfire.xml
/WEB-INF/xfire-servlet.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>