1.找到web.xml
如果只想修改tomcat的,就打开root目录下conf的web.xml
如果是运行的某个项目的,就打开webapp下的那个项目的web-inf文件夹下的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>
</web-app>
2.在wepapp文件夹中的 项目文件夹下
加error.html文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<!-- header -->
<div id="header">
<h1>No pages here as you see!<span>404 error - not found.</span></h1>
</div>
<!-- content -->
<div id="content">
<ul class="nav">
<li class="home"> <a href="#"> </a></li>
<li class="site_map"><a href="#"> </a></li>
<li class="search"><a href="#"> </a></li>
</ul>
<p>You didn't wirte correct information!</p>
<p>Go back and do it seriously!</p>
</div>
<!-- footer -->
<div id="footer">
Designed by TemplateMonster - all <a href="http://www.cssmoban.com" target="_blank">网页模板</a> found and safe!
</div>
</div>
</body>
</html>
3…在wepapp文件夹中的 项目文件夹下
加images文件夹main-bg.jpg
4…在wepapp文件夹中的 项目文件夹下
加style.css
* {
margin:0;
padding:0;
}
html, body {
height:100%;
}
body {
background:#000;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:100%;
line-height:1em;
color:#afa196;
font-weight:bold;
}
img {
border:0;
vertical-align:top;
text-align:left;
}
ul, ol {
list-style:none;
}
.wrapper {
width:100%;
overflow:hidden;
}
/*==== GLOBAL =====*/
#main {
width:1000px;
margin:0 auto;
background:url(images/main-bg.jpg) no-repeat left top;
font-size:.9375em;
}
#header {
height:190px;
}
#content {
min-height:457px;
height:auto !important;
height:457px;
}
#footer {
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:12px;
text-align:center;
padding:10px 0 0 0;
font-weight:normal;
}
#footer a {
color:#333;
}
p {
margin-bottom:8px;
text-align:center;
padding:0 35px;
letter-spacing:-1px;
}
/*----- txt, links, lines, titles -----*/
a {
color:#fff;
outline:none;
}
a:hover{
text-decoration:none;
}
h1 {
font-size:50px;
line-height:1.1em;
font-weight:normal;
color:#afa196;
text-align:center;
padding:94px 0 0 0;
text-transform:capitalize;
font-variant:small-caps;
letter-spacing:-2px;
}
h1 span {
display:block;
font-size:20px;
line-height:25px;
color:#6b635e;
font-variant:normal;
text-transform:none;
letter-spacing:0;
font-weight:bold;
letter-spacing:-1px;
}
/*===== content =====*/
#content .nav {
position:relative;
height:368px;
}
#content .nav li {
position:absolute;
font-size:20px;
line-height:1.2em;
font-weight:bold;
text-transform:uppercase;
font-weight:normal;
letter-spacing:-1px;
}
#content .nav li.home {
left:451px;
top:270px;
}
#content .nav li.site_map {
left:120px;
top:60px;
}
#content .nav li.search {
right:90px;
top:60px;
}
#content .nav li a {
color:#d6cab9;
text-decoration:none;
}
#content .nav li a:hover {
text-decoration:underline;
}
/*==========================================*/
5.完成后重新运行tomcat