受够了Tomcat默认的那个错误页面

还有就是报错页面一样的难看!~

ok分享一个方法:

1.首先准备一个漂亮的错误页面:404.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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>您访问的页面不存在</title>
<style type="text/css">
/*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;
}
</style>
<script type="text/javascript">function returnHistory(){window.history.go(-1);}
</script>
</head><body><!-- 头部背景 -->
<div class="yelangsembg"> <!-- 头部导航 --><!-- 头部导航 结束 --><!--通栏广告1--><div class="nav"><div class="wrap"><!--  <em>访问页面出错</em>--></div></div><!--通栏广告1 结束--><div class="wrap" style="margin-top:85px;"><div class="w7"> <span><img src="http://localhost:8080/SinoWIFI/images/404.gif"></span> <span><h1 style="">抱歉,您请求的页面现在暂时无法打开</h1><h2>您可以:</h2><p><a href="http://localhost:8080/SinoWIFI/" >返回首页</a><a href="#" οnclick="returnHistory()">返回上一级</a></p><h3>本页面将在<em id="timeout">4</em>秒钟后自动转到首页,请稍后...</h3></span> </div></div><script type="text/javascript">(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);
})();</script>
</div>
</body>
</html>

404.gif图片:

在web.xml中添加配置:

<error-page><exception-type>java.lang.Exception</exception-type><location>/404.html</location></error-page><error-page><error-code>404</error-code><location>/404.html</location></error-page><error-page><error-code>400</error-code><location>/404.html</location></error-page><error-page><error-code>500</error-code><location>/404.html</location></error-page>

ok,现在我们可以测试一下,在项目这个中随便输入地址:

方便快捷!~包教包会!~

如何处理tomcat默认错误页面相关推荐

  1. 如何自定义Tomcat 404错误页面

    分享一下我老师大神的人工智能教程.零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow 点击这里使用RSS ...

  2. weblogic 替换默认错误页面_weblogic 部署后出现Error 404–Not Found

    Error 404--Not Found 错误 From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1: 10.4.5 404 Not Found ...

  3. Tomcat默认访问页面

    设置 /config/web.xml <welcome-file-list>          <welcome-file>index.html</welcome-fil ...

  4. java tomcat 404配置_在Tomcat中配置404自定义错误页面详解

    一直使用tomcat,今天想到一个问题,自定义404错误页面, 为了获得很好的用户感受,是不应当向用户暴露404这样的页面的, 问题的出发点是我在Struts2中定义错误页面, 在Struts2中是这 ...

  5. jsp错误处理页面_JSP异常处理– JSP错误页面

    jsp错误处理页面 Exception handling in JSP is done by JSP exception pages. JSP异常页面中完成了JSP中的异常处理. JSP中的异常处理 ...

  6. Spring Security第2部分–密码加密,自定义404和403错误页面

    这是Spring安全站的第二部分. 在这篇文章中,我将向您展示如何使用MD5加密密码以及自定义403和404状态代码错误页面. 如果您尚未阅读第1部分,请单击 此处 . 因为我们在这里继续第1部分项目 ...

  7. SharePoint 调查列表的自定义错误页面

    场景: 使用SharePoint的调查列表做调查问卷的时候,我们经常要设置成不允许多次答复,这样的话每个人就只能答复一次. 问题: 可是这样会产生一个问题,就是如果一个人第二次答复的话,那么出现的错误 ...

  8. nginx配置错误页面,处理tomat版本号泄露问题

    一.问题描述 项目做安全扫描时,Tomcat报错页面泄漏Apache Tomcat/7.0.52相关版本号信息,安全策略要求去掉版本号信息. 二.解决方法 网上搜了下,大多都是简单粗暴的处理,直接去掉 ...

  9. SpringBoot之自定义错误页面

     SpringBoot 默认配置: 如果是浏览器请求URL错误,返回错误页面:如果是postman等非浏览器客户端请求URL错误,返回 json 数据: SpringBoot源码: @Controll ...

  10. tomcat配置400/404/500类型的错误页面,修改项目默认路径,修改默认项目

    修改项目默认路径,修改默认项目  http://xxx.xxxxxx.xxx  直接访问 找到tomcat路径中conf文件夹下server.xml文件找到 <Host name="l ...

最新文章

  1. golangsha1解码_golang中几种加密方式的处理
  2. Mysql 主从复制(AB复制)
  3. 基于对象和面向对象编程范式辨析和主流编程语言中的应用
  4. 项目管理基础:软件生命周期概念介绍
  5. 对那些刷抖音外放音乐的人,就这么治他!| 今日最佳
  6. python来进行图的深度遍历和广度遍历
  7. linux登录后自动打开终端,linux登录信息/打开终端信息
  8. JS:ES6-7 迭代器与生成器
  9. IDEA的创建javaWeb工程以及修改默认的class文件输出
  10. 给csdn主页添加个人联系方式或二维码
  11. 测试Live Write的发布功能
  12. 查找算法之四 斐波那契查找(C++版本)
  13. C语言判断m数为素数,判断数m是否为素数 c语言求素数的代码
  14. R语言安装包下载和安装
  15. Golang defer、panic和recover
  16. 好玩有趣的 iOS URL Scheme
  17. mac环境 java找不到或无法加载主类
  18. JAVA学习:基础入门(下)
  19. MYSQL的自增长字段可以赋值
  20. 漫话:什么是 https ?这应该是全网把 https 讲的最好的一篇文章了

热门文章

  1. ps2021没法用神经元滤镜,ps2021神经滤镜不能下载
  2. 明解C语言【中级篇】
  3. HTML生日快乐代码
  4. matlab绘制均匀b样条曲线_[转载]用matlab实现B样条曲线
  5. R语言怎么写积分_2020年上海居住证积分申请表怎么填?个人履历该怎么写?—积分落户服务站...
  6. Linux开发之libaio源码分析及应用
  7. 《凤凰项目 一个IT运维的故事传奇》读后感
  8. matlab 矩阵逻辑与,MATLAB矩阵的寻访与赋值
  9. 贾俊平《统计学》常用公式
  10. Java设计模式学习记录-模板方法模式