在進行spring和struts2整合的時候因為大意遇到了一個問題,費了半天神終於找到了問題所在,故分享出來望廣大博友引以為戒!!
我們都知道在spring和struts2整合時,spring接管了action對象的創建,所以一定要在spring配置文件中配置action,這里需要注意的是配置<bean id="???">中的id時,
要與struts.xml配置action中的<action class="???">class一致,否則就會出現如下問題:
樓主就是因為把struts.xml配置action中的class寫成了action類路徑,導致了這個問題,所以親們一定要注意!
錯誤配置代碼:applicationContext.xml中<bean id="cartAction" class="com.ansibee.shop.web.action.CartAction" scope="prototype">
struts.xml中<action name="cart_*" class="com.ansibee.shop.web.action.CartAction" method="{1}">
正確配置代碼:applicationContext.xml中<bean id="cartAction" class="com.ansibee.shop.web.action.CartAction" scope="prototype">
struts.xml中<action name="cart_*" class="cartAction" method="{1}">