隐藏Tomcat版本号信息

在tomcat/conf/web.xml中添加error-page.

 

另外在工程的web.xml中也可以配置error-page,有两种配置方法,

一. 是通过错误码

 

<error-page>
        <error-code>500</error-code>
        <location>/WEB-INF/error.html</location>
  </error-page>


二. 是通过异常的类型配置

 

 

<error-page>
        <exception-type>java.lang.NullException</exception-type>
        <location>/WEB-INF/error.html</location>
   </error-page>

 

 

 

 

 

注意location指定的是绝对路径。

 

error.html

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>系统出现错误,我们会尽快修复,对您造成不便我们感到非常抱歉。</title>
    <style type="text/css">
        .ui-error-box{
 
            background-image: url(/images/error_bj.jpg); height:260px; width: 410px; margin: 80px auto;
            color: #eb6100; font-weight: bold; padding: 140px 0 0 198px;
         
}
        .ui-error-box a{
 			color: #037cd6; margin-right: 20px;
}
 
    </style>
</head>
<body>
    <div class="ui-error-box">
        <p>资源不存在或者系统内部错误<br>对您造成不便我们感到非常抱歉。</p>
    </div>
</body>

 

最后欢迎大家访问我的个人网站:1024s

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值