1、没有项目名称的 404
eg:
比如你的项目名称为 demoManage
本地环境的 URL 应该为: http://127.0.0.1/demoManage
但是用户却输入了 http://127.0.0.1/33ss 反正后面的项目名不是 demoManage
这是就会报 404
解决方法:
在tomcat 的conf目录下的 web.xml加入
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
其中 404.jsp 存放在/webapps/ROOT 目录下
注:这个404.jsp页面没有在你的项目下
2、项目名称正确但是后面的地址错误 的404
eg:
比如你的项目名称为 demoManage
本地环境的 URL 应该为: http://127.0.0.1/demoManage/
用户http://127.0.0.1/demoManage/ 在这个后面输入错误地址引发 404
解决方法:
在你项目的 web.xml 中配置
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
注:这个404.jsp是在你项目中的。