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

Eclipse运行Tomcat部署动态Web项目时出现404错误求助

Eclipse部署Dynamic Web项目根路径404问题解决方案

你遇到的报错为:

HTTP Status 404 – Not Found
Type: Status Report
Message: The requested resource [/ddddd/] is not available
Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.45

单独运行项目内html、jsp文件正常,说明项目本身部署成功,问题出在Tomcat找不到项目根路径对应的默认响应资源,可按以下步骤排查解决:

  • 检查web.xml欢迎页配置
    打开项目WebContent/WEB-INF/web.xml文件,确认存在<welcome-file-list>配置节点,并且节点内包含你需要作为首页的文件名称,参考配置如下:
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    
    注意:如果首页文件存放在子文件夹下,需要填写相对于WebContent目录的完整相对路径,例如home/index.html。
  • 校验项目上下文路径配置
    右键项目 -> 选择Properties -> 进入Web Project Settings页面,确认Context root的值为ddddd,和访问路径的前缀保持一致。修改后需重启Tomcat、重新部署项目生效。
  • 调整Tomcat部署配置
    打开Eclipse的Servers视图 -> 双击对应Tomcat v9.0服务器 -> 找到Server Locations配置区域,选择Use Tomcat installation (takes control of Tomcat installation),同时确认Deploy path取值为webapps。修改后右键Tomcat选择Clean清空工作目录,重新发布项目后测试。
  • 排查Servlet映射冲突
    如果你项目中配置了映射路径为/的全局Servlet,会覆盖Tomcat默认的根路径处理逻辑,导致根路径访问404。可调整该Servlet的映射路径,或在Servlet代码中添加根路径请求跳转到首页的逻辑。
  • 清理缓存重新部署
    选择菜单栏Project -> 点击Clean清理项目缓存,右键Tomcat服务器选择Add and Remove,先移除当前项目再重新添加,启动服务器后再次测试访问。

内容的提问来源于stack exchange,提问作者Mehedi Hassan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.15 20:24:09