Apache Tomcat错误页面

问题描述 投票:0回答:1

我正在使用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目录中。

java apache tomcat custom-error-pages
1个回答
0
投票

如果你想让它变成泛型,我建议你在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/

© www.soinside.com 2019 - 2024. All rights reserved.