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

时间:2024-03-31 09:28:41

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

问题描述

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

解决Web项目因访问URL与Tomcat服务器文件夹相同导致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.

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

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

解决方法

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

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