如何在tomcat中构建服务器级自定义错误页面? [英] how to build server level custom error page in tomcat?

查看:34
本文介绍了如何在tomcat中构建服务器级自定义错误页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台 tomcat Web 服务器上部署了多个 Web 应用程序.对于所有已部署的 Web 应用程序,如果任何 Web 应用程序中发生 404 错误,我想显示相同的 404.jsp 页面.

i have multiple web applications deployed on one tomcat web server. for all deployed web application, i want to display same 404.jsp page if 404 error occurred in any web application.

一种方法是在每个 Web 应用程序的 web.xml 中放入 404 条目,并为 404.jsp 提供适当的位置.

One way is to put an entry of 404 in each web application's web.xml and give proper location to the 404.jsp.

有什么办法可以让所有网络应用程序在 404 错误时显示 ROOT 的 404 页面??

Is there any way so that all web application will display ROOT's 404 page on 404 error??

谢谢,帕文

推荐答案

你可以把这个添加到 $CATALINA_HOME/conf/web.xml

You can add this to the $CATALINA_HOME/conf/web.xml

<error-page> 
    <error-code>404</error-code>
    <location>/error/404.html</location>
</error-page>

并添加一个具有该页面的 web 应用程序,并将回答

And add a webapp that has the page and will answer to the URL under <location>

这篇关于如何在tomcat中构建服务器级自定义错误页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆