首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

Struts2 導入專案報 404:welcome-file-list 配置錯誤

     編輯:程式設計綜合問答

報錯 HTTP Status 404 - /16/WebRoot/admin_index.jsp,且 `web.xml` 設定 `index.jsp`,但實際入口為 `admin_index.jsp`,導致專案根路徑無法自動導向正確頁面。

修正 web.xml

<welcome-file-list>
  <welcome-file>admin_index.jsp</welcome-file> <!-- 改為實際入口頁 -->
</welcome-file-list>

完整檢查清單

  1. ✅ `web.xml` 中 `` `` 正確攔截 `/*` (Struts2 核心)。
  2. ✅ `struts.xml` `` 對應根路徑,Action 結果 `/admin_index.jsp` 路徑正確。
  3. ✅ 專案部署路徑:Eclipse → Server → 模組路徑應為 `/16` (而非 `/16/WebRoot`)。
  4. ✅ `admin_index.jsp` 實際位於 `WebContent/` 或 `webapp/` 目錄下 (非 `WEB-INF`)。

常見誤區

  • 以為 404 是 Action 映射錯 → 實際是歡迎頁面配置錯,直接訪問 `https://localhost:8080/16/admin_index.jsp` 通常能通。
  • Struts 2.5+ 建議用 `` 避免命名空間匹配問題。

修正 `` 後重新部署,專案根路徑即可正確導向登入頁。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved