我正在使用Apache Tomcat v7.0.63,它托管了4个不同的应用程序。其中一个应用程序具有错误页面列表。
现在我们想让它通用,以便其他应用程序也可以使用相同的错误页面。这样,我们就不需要在所有Web应用程序中保留重复文件。我们希望将所有错误页面保存在tomcat / errorPages目录或tomcat / conf / errorPages目录下。
我尝试修改/tomcat/webapps/MyApplication/WEB-INF/web.xml文件,如下所示,它无法正常工作。有人可以帮忙吗?
</error-page>
<error-page>
<error-code>404</error-code>
<location>/../../errorPages/errorPage404.html</location>
</error-page>
并且errorPage404.html位于/ tomcat / errorPages目录中。
如果你想让它变成泛型,我建议你在TOMCAT_HOME/conf/web.xml
中定义错误。它将覆盖Tomcat
附带的默认错误页面。
<error-page>
<error-code>500</error-code>
<location>/server_error.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/file_not_found.html</location>
</error-page>
确保将错误页面移动到位置/webapps/ROOT/