如何在服务器级别而不是应用程序级别更改tomcat的默认错误页面



我在Tomcat上使用了一个https:abc:8443/appname/login应用程序。我已经配置了应用程序,这样如果我搜索https://abc:8443/appname/prasfag.txt,就会显示我的自定义错误页面。

但是,如果我搜索https://abc:8443/prags.txt,tomcat会显示默认的错误404页面。我希望tomcat在我访问https://abc:8443/prags.txt时显示一个自定义页面。

如何配置?

在tomcat web.xml中,您可以配置HTTP重定向页面。只需插入

<error-page>
<error-code>-xxx-</error-code>
<location>/your/custom/html/path.html</location>
</error-page>

在您的web.xml 中

最新更新