1.確保以下幾個jar不在project build path里面,否則會出現各種沖突問題.
c3p0-0.9.0.4.jar
asm-2.2.3.jar
hibernate-annotations.jar
2.添加順序->spring,hibernate,struts
3.修改 struts-config.xml
action-mappings標簽里面的type改為org.springframework.web.struts.DelegatingActionProxy
例如:
<action attribute="userSearchForm" input="/userSearch.jsp"
name="userSearchForm" path="/userSearch" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="success.jsp" />
</action>
最后加上
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
4.applicationContext.xml里面添加
<bean name="/userSearch" class="com.oocl.struts.action.UserSearchAction">
<property name="actionLogDAO">
<ref bean="AlActionlogDAO" />
</property>
</bean>
這里的要注意,是name="/userSearch"不是id
還有,要確認好這個property的name一定要和你的bean class里面的field符合
5.myEclipse添加spring,hibernate,struts支持的時候,盡量把所有的jar都包含進來吧,然后把不需要的給刪除掉.