vim /conf/web.xml
在文件末尾,</web-app>的前面,加上以下内容:
    <error-page>
        <error-code>400</error-code>

        <location>/error.html</location>

    </error-page>

    <error-page>
        <error-code>404</error-code>

        <location>/error.html</location>

    </error-page>

    <error-page>
        <error-code>500</error-code>

        <location>/error.html</location>

    </error-page>

之后在/webapps/ROOT下面添加error.html文件(该页面可以替换成你自己自定义的界面):

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>网页访问不了</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="404/error_all.css?t=201303212934">
</head>

<body class="error-404">
<div id="doc_main">

<section class="bd clearfix">
<div class="module-error">
<div class="error-main clearfix">
<div class="label"></div>

<div class="info">
<h3 class="title">啊哦,你所访问的页面不存在了,可能是炸了</h3>

<div class="reason">
<p>可能的原因:</p>

<p>1.手抖打错了。</p>

<p>2.链接过了保质期。</p>

</div>

</div>

</div>

</div>

</section>

</div>

</body></html>

image-20250430101844199

results matching ""

    No results matching ""