web.xml中welcome-file配置的問題__web

來源:互聯網
上載者:User

       最近在搭建maven項目,剛開始配置了welcome-file的是jsp,沒有什麼問題,後來整合struts2,spring時寫了一個測試action,當我將welcome-file改成action後,運行發現找不到檔案,後來查了很多資料才知道。

welcome-file的只能只對serlvet,html,jsp。而struts2是用filter來做的所以無法識別,解決方案有3種。

1.網頁重新導向,在welcome-file中<welcome-file>index.jsp</welcome-file>  ,在index.jsp中的meta寫<meta http-equiv="refresh" content="0;url=index.action"> 

   2.網頁跳轉  在index.jsp的使用jsp:forword的標籤跳轉到index.action

   3.在web.xml的welcome-file中直接寫<welcome-file>index.action</welcome-file>,然後在項目的根目錄下建立一個index.action的空檔案就可以正常運行,

Ps:目前只在tomcat下可以運行(測試過),jetty中貌似不可以(有網友說的,未測試),建議還是使用第一種或者第二種

參考資料:http://www.jdiy.org/read.jd?id=y0hi94eg4l

http://yjshengshe.iteye.com/blog/641934


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.