tomcat错误页重定向
当tomcat出现404界面之后跳转到默认页
可以将此页重新定位到其他指定界面:
1、创建新的错误页
编写新的界面error.html,将此界面放到 tomcat6/webapps/root 目录下
2、创建编写web.xml
修改tomcatwebappsrootweb-infweb.xml文件内容,指定错误状态码对应的界面
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true"> <display-name>welcome to tomcat</display-name> <description>welcome to tomcat</description> <error-page> <error-code>404</error-code> <location>/error.html</location> </error-page> <error-page> <error-code>400</error-code> <location>/error.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/error.html</location> </error-page> </web-app>
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论