You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在STS中运行Apache Tomcat时index.html报HTTP 404错误求助

解决Spring Tool Suite 4动态Web项目中index.html访问404问题

问题描述

运行Spring Tool Suite 4中的动态Web项目时,访问基础index.html文件出现以下错误:

HTTP Status 404 – Not Found
Type Status Report

已尝试删除并重新创建Tomcat服务器,且确认所有配置无误,但仍未解决问题。

排查及解决方向

  • 确认文件位置:保证index.html放在项目的WebContent(普通动态Web项目)或src/main/webapp(Maven项目)根目录下,不要嵌套在子文件夹内
  • 核对部署路径:在Tomcat服务器的部署配置里,检查项目的上下文路径是否正确,访问URL要和上下文路径匹配(比如上下文路径是/mywebapp,就需要访问http://localhost:8080/mywebapp/index.html)
  • 查看Tomcat日志:打开Tomcat安装目录下logs文件夹里的localhost.log或localhost_access_log.*.txt,确认请求的URL是否正确,以及项目是否成功部署
  • 重新构建项目:右键项目执行Clean操作(Maven项目选Run As → Maven Clean,普通项目直接选Clean),之后重新部署到Tomcat
  • 检查Web.xml配置:如果项目里有web.xml,确认默认欢迎页面配置是否包含index.html:
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

内容的提问来源于stack exchange,提问作者Dinesh Kumar Lalam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 21:57:36