解决Web项目因访问URL与Tomcat服务器文件夹相同导致404页面的问题

本文解决Web项目中访问URL与Tomcat服务器文件夹名称相同导致的404错误。通过调整路径避免与服务器内置应用冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决Web项目因访问URL与Tomcat服务器文件夹相同导致404页面的问题

问题描述

我们知道,客户端如果请求的URL不存在的话,会在页面显示一个404的错误,如下图

404页面

但我在访问资源的时候出现了下面这种情况的404页面,显示以下的文字

404 Not found
The page you tried to access (/manager/addnews) does not exist.
The Manager application has been re-structured for Tomcat 7 onwards and some of URLs have changed. All URLs used to access the Manager application should now start with one of the following options:
/manager/html for the HTML GUI
/manager/text for the text interface
/manager/jmxproxy for the JMX proxy
/manager/status for the status pages
Note that the URL for the text interface has changed from “/manager” to “/manager/text”.
You probably need to adjust the URL you are using to access the Manager application. However, there is always a chance you have found a bug in the Manager application. If you are sure you have found a bug, and that the bug has not already been reported, please report it to the Apache Tomcat team.

这里写图片描述

因为我是能够保证我的访问路径是正确的,所以想了好久没想明白,到最后自己随意改了一个路径,居然就可以运行了。下面就说一说解决的方法。

解决方法

  • 这个的问题主要是路径与Tomcat服务器的文件夹重名了,例如我访问的那么/manager,它其实是Tomcat的子文件夹,里面没有包含你想要的东西,所以自然访问不到资源,但返回的却是奇怪的404。最后我把manager这个路径修改一下就访问正确了,所以我们以后路径名不能跟服务器的路径冲突。
  • 因为笔者也被这个坑了很久,且在网上找不到很好地解决方法,所以把我的经历写在这里,希望能帮上遇到同样情况的同学。

欢迎大家转载,但请标明转载链接。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值