在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