struts2整合spring3启动不报错并且提示整合成功
但是在action里面无法使用spring无法注入的dao或者service的解决办法是:
1、检查配置文件是否真的没有问题
2、在struts.xml里面将action配置对应的class配置的路径修改成 在application.xml配置对应action的name属性
修改前:
<package name="web" namespace="/" extends="struts-default">
<action name="chang" class="com.ripsoft.web.action.Chang">
<result name="success">/welcome.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
</struts>
修改后:
<struts>
<package name="web" namespace="/" extends="struts-default">
<action name="chang" class="wjmjAction">
<result name="success">/welcome.jsp</result>
<result name="input">/index.jsp</result>
</action>
</package>
</struts>
spring配置文件不变:
<!-- action -->
<bean name="wjmjAction" class="com.ripsoft.web.action.Chang">
<property name="bafService">
<ref bean="baffyService"/>
</property>
<property name="stu">
<ref bean="stuservice"/>
</property>
</bean>
原因很怪异,因为以前我都没有做个这样的修改struts2和spring3是可以完美整合的,只是最近在项目上加了web service的包才导致这样的问题,百度了下发现是struts.xml配置文件里面class包含了包得全名的问题,后面再研究。