Tomcat設定顯示首頁問題
阿新 • • 發佈:2019-01-26
Spring遇見問題(一)-----預設首頁顯示問題
最近在搭建一個web專案,我發現怎麼首頁總是404錯誤,找不到呢?就查了一下<welcome-file>標籤的使用,發現這個標籤早在tomcat中就已經定義好了,而在自己的web工程進行修改時,並沒有覆蓋之前的配置。
TOMCATHOME/conf/web.xml
<welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
而自己的web工程中,WEB-INF/web.xml
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
並不好用。找不到頁面,404錯誤。
tomcat conf目錄下的為伺服器全域性作用域,一般用來配置全域性設定、資料來源等,而專案目錄下的為區域性作用域。
出現404找不到首頁的解決方案:
1,檢查指向的頁面是否存在
2,<welcome-file>xxx.html</welcome>路徑是否正確
<welcome-file>/WEB-INF/jsp/xxx.html</welcome>
3,實在沒有辦法時修改Tomcat下的conf/web.xml檔案的<welcome-file>xxx.html</welcome>
注:親測,對於載入了Spring mvc後定義的首頁資訊就無法找到了,可能是發生衝突了。