受够了Tomcat默认的那个错误页面
还有就是报错页面一样的难看!~
ok分享一个方法:
1.首先准备一个漂亮的错误页面:404.html
您访问的页面不存在/*reset及 clear*/
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, p, blockquote, table, th, td, embed, object, button {
margin:0;
padding:0;
font-size:12px;
color:#343434;
font-family:"宋体", Arial, Helvetica;
word-wrap:break-word;
}
fieldset, img, abbr {
border:0;
}
address, caption, cite, code, dfn, em, strong, th, var, i, b {
font-weight:normal;
font-style:normal;
}
ul, ol {
list-style:none;
}
a, a:link, a:visited, a:active {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
a:focus, input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
outline:none;
}
.cl0, .cl5, .cl10, .cl15, .cl20 {
clear:both;
overflow:hidden;
font-size:0;
}
.cl0 {
height:0px;
}
.cl5 {
height:5px;
}
.cl10 {
height:10px;
}
.cl15 {
height:15px;
}
.cl20 {
height:20px;
}
.nav {
width:100%;
background:url(404/404navbg.jpg) repeat-x;
height:39px;
}
.wrap {
width:980px;
margin:0 auto;
}
.nav .wrap em {
color:#f5e2c2;
font: bold 16px/39px "宋体";
padding-left:40px;
}
.tl {
text-align:left;
}
.tc {
text-align:center;
}
.tr {
text-align:right;
}
.box {
border:1px solid #dedddd;
border-radius:3px;
}
/*颜色*/
.purity_red {
color:#f00;
}
.fred {
color:#b01f2e;
}
.fyellow {
color:#ead6b3;
}
/*字体大小*/
.fs12 {
font-size:12px;
}
.fs14 {
font-size:14px;
}
/*头部背景*/
html {
_background-attachment:fixed;
_background-image:url(nothing.txt);
}
body {
background:url(404/topbg.jpg) #fbfbfb repeat-x;
height:100%;
}
.yelangsembg {
background:url(404/headbackbg.jpg) no-repeat center top;
padding-top:0px;
}
/*正文*/
.w7 {
width:770px;
margin:0 auto;
}
.w7 span {
display:inline-block;
height:170px;
margin-left:60px;
}
.w7 h1 {
color:#a21e2c;
font-size:26px;
font-family:"微软雅黑";
}
.w7 h2 {
color:#666;
font: bold 16px "宋体";
margin:10px 0;
}
.w7 h3 {
color:#666;
font: bold 14px "宋体";
margin:10px 0;
}
.w7 h3 em {
font-size:22px;
color:#aa2230;
padding:0 5px;
font-weight:bold;
}
.w7 span p a {
font: bold 14px/32px "新宋体";
color:;
display:inline-block;
background:url(404/404bt.jpg) no-repeat;
text-align:center;
width:106px;
height:32px;
margin-left:20px;
}
function returnHistory(){
window.history.go(-1);
}
(function(){
var timeout = 0;
var handler = function(i){
document.getElementById("timeout").innerHTML = (10 - i);
if(i < 10)
{
var method = arguments.callee;
setTimeout(function(){method(i + 1);}, 1000);
}
else
{
document.location="http://localhost:8080/SinoWIFI/";
}
};
handler(0);
})();
404.gif图片:
在web.xml中添加配置:
java.lang.Exception
/404.html
404
/404.html
400
/404.html
500
/404.html
ok,现在我们可以测试一下,在项目这个中随便输入地址:
方便快捷!~包教包会!~