1. 程式人生 > >SSH中spring和struts2整合遇到的問題,Action class not found

SSH中spring和struts2整合遇到的問題,Action class not found

我們在對sturts.xml配置檔案中的action進行配置時,action指向的class往往是spring配置檔案applicationContext.xml中的been名,這時候出現了action class not found的問題。檢查action定義正確,仍報錯。可能有下列兩個原因:
1.未匯入struts2-sping-plugin 2.0.1.jar(在struts包中)
struts2-sping-plugin 2.0.1.jar用於將struts.xml配置檔案和spring配置檔案關聯起來。在lib中匯入struts2-sping-plugin 2.0.1.jar即可
2.struts.xml沒有交與spring管理
在struts.xml中還要加入這麼一個bean
<bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />

這個bean要放在package的外面