目录
- Tomcat错误页重定向
- 1、创建新的错误页
- 2、创建编写web.xml
- 总结
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>
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持悠久资源。