HTTP Status 404 - No result defined for action解決方案 使用myeclipse10繼承spring2.5+struts2
google了一把原來是struts.xml 裡面<package name="default" extends="struts-default" namespace="/"> 缺少了namespace="/"。
No result defined for action and result input的錯誤很常見,那是沒有配置出錯時的預設視圖,出現這類現象,你可以檢查如下幾個方面:
1、頁面中是否有重名的控制項,就是說頁面中的控制項或隱藏欄位中有相同名字的控制項,而它們在Action中又給引用到。其中把控制項放在<s:iterator>中尤為常見。
2、return的視圖在設定檔中是否存在,建議開啟檔案後用搜尋,有時名字長點,英語字母看亂了。
3、頁面傳回值與Action中定義是否一致,傳回值是否會出多一些莫名其妙的東西
4、嘗試給頁面的空值設預設值
5.在package裡加上namespace屬性即(namespace="/")
Struts2+Spring的時候
import com.opensymphony.xwork2.ActionSupport; 匯入這個正確
import org.springframework.web.struts.ActionSupport; 匯入錯誤
Struts2+Spring2.5整合的jar包
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
freemarker-2.3.18.jar
javassist-3.11.0.GA.jar
ognl-3.0.4.jar
spring.jar
struts2-core-2.3.1.2.jar
struts2-spring-plugin-2.2.1.jar
xwork-core-2.3.1.2.jar
步驟:
1.匯入struts2jar包,以及struts2-spring-plugin.jar
2.在web.xml中分別配置struts2與Spring相關資訊
3.在spring配置action bean
4.在struts2的設定檔中,調用 spring bean