Spring 整合struts問題

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.