tomcat和nginx自定义404错误页面

nginx

编辑nginx配置文件

vim /www/server/nginx/nginx.conf

server{listen 80;error_page 404  /404.html;location = /404.html{root    /home/liu/html/error-html;}
}

在家目录下创建一个html/error-html目录,用于存放错误页面
在error-html目录下创建404.html,里面写404代码

tomcat

配置web.xml

vim webapp/WEB-INF/web.xml

添加如下内容

	<error-page><error-code>404</error-code><location>/404.html</location></error-page>

在项目根目录下创建404.html文件

这里提供几个网上找的几个有意思的404页面源码

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>404,网页丢失啦</title><style>
body {background: #000;height: 100vh;overflow: hidden;display: flex;font-family: 'Anton', sans-serif;justify-content: center;align-items: center;-webkit-perspective: 1000px;perspective: 1000px;
}div {-webkit-transform-style: preserve-3d;transform-style: preserve-3d;
}.rail {position: absolute;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;-webkit-transform: rotateX(-30deg) rotateY(-30deg);transform: rotateX(-30deg) rotateY(-30deg);
}
.rail .stamp {position: absolute;width: 200px;height: 200px;display: flex;justify-content: center;align-items: center;background: #141414;color: #fff;font-size: 7rem;
}
.rail .stamp:nth-child(1) {-webkit-animation: stampSlide 40000ms -2300ms linear infinite;animation: stampSlide 40000ms -2300ms linear infinite;
}
.rail .stamp:nth-child(2) {-webkit-animation: stampSlide 40000ms -4300ms linear infinite;animation: stampSlide 40000ms -4300ms linear infinite;
}
.rail .stamp:nth-child(3) {-webkit-animation: stampSlide 40000ms -6300ms linear infinite;animation: stampSlide 40000ms -6300ms linear infinite;
}
.rail .stamp:nth-child(4) {-webkit-animation: stampSlide 40000ms -8300ms linear infinite;animation: stampSlide 40000ms -8300ms linear infinite;
}
.rail .stamp:nth-child(5) {-webkit-animation: stampSlide 40000ms -10300ms linear infinite;animation: stampSlide 40000ms -10300ms linear infinite;
}
.rail .stamp:nth-child(6) {-webkit-animation: stampSlide 40000ms -12300ms linear infinite;animation: stampSlide 40000ms -12300ms linear infinite;
}
.rail .stamp:nth-child(7) {-webkit-animation: stampSlide 40000ms -14300ms linear infinite;animation: stampSlide 40000ms -14300ms linear infinite;
}
.rail .stamp:nth-child(8) {-webkit-animation: stampSlide 40000ms -16300ms linear infinite;animation: stampSlide 40000ms -16300ms linear infinite;
}
.rail .stamp:nth-child(9) {-webkit-animation: stampSlide 40000ms -18300ms linear infinite;animation: stampSlide 40000ms -18300ms linear infinite;
}
.rail .stamp:nth-child(10) {-webkit-animation: stampSlide 40000ms -20300ms linear infinite;animation: stampSlide 40000ms -20300ms linear infinite;
}
.rail .stamp:nth-child(11) {-webkit-animation: stampSlide 40000ms -22300ms linear infinite;animation: stampSlide 40000ms -22300ms linear infinite;
}
.rail .stamp:nth-child(12) {-webkit-animation: stampSlide 40000ms -24300ms linear infinite;animation: stampSlide 40000ms -24300ms linear infinite;
}
.rail .stamp:nth-child(13) {-webkit-animation: stampSlide 40000ms -26300ms linear infinite;animation: stampSlide 40000ms -26300ms linear infinite;
}
.rail .stamp:nth-child(14) {-webkit-animation: stampSlide 40000ms -28300ms linear infinite;animation: stampSlide 40000ms -28300ms linear infinite;
}
.rail .stamp:nth-child(15) {-webkit-animation: stampSlide 40000ms -30300ms linear infinite;animation: stampSlide 40000ms -30300ms linear infinite;
}
.rail .stamp:nth-child(16) {-webkit-animation: stampSlide 40000ms -32300ms linear infinite;animation: stampSlide 40000ms -32300ms linear infinite;
}
.rail .stamp:nth-child(17) {-webkit-animation: stampSlide 40000ms -34300ms linear infinite;animation: stampSlide 40000ms -34300ms linear infinite;
}
.rail .stamp:nth-child(18) {-webkit-animation: stampSlide 40000ms -36300ms linear infinite;animation: stampSlide 40000ms -36300ms linear infinite;
}
.rail .stamp:nth-child(19) {-webkit-animation: stampSlide 40000ms -38300ms linear infinite;animation: stampSlide 40000ms -38300ms linear infinite;
}
.rail .stamp:nth-child(20) {-webkit-animation: stampSlide 40000ms -40300ms linear infinite;animation: stampSlide 40000ms -40300ms linear infinite;
}@-webkit-keyframes stampSlide {0% {-webkit-transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(130px);transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(130px);}100% {-webkit-transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(-3870px);transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(-3870px);}
}@keyframes stampSlide {0% {-webkit-transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(130px);transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(130px);}100% {-webkit-transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(-3870px);transform: rotateX(90deg) rotateZ(-90deg) translateZ(-200px) translateY(-3870px);}
}
.world {-webkit-transform: rotateX(-30deg) rotateY(-30deg);transform: rotateX(-30deg) rotateY(-30deg);
}
.world .forward {position: absolute;-webkit-animation: slide 2000ms linear infinite;animation: slide 2000ms linear infinite;
}
.world .box {width: 200px;height: 200px;-webkit-transform-origin: 100% 100%;transform-origin: 100% 100%;-webkit-animation: roll 2000ms cubic-bezier(1, 0.01, 1, 1) infinite;animation: roll 2000ms cubic-bezier(1, 0.01, 1, 1) infinite;
}
.world .box .wall {position: absolute;width: 200px;height: 200px;background: rgba(10, 10, 10, 0.8);border: 1px solid #fafafa;box-sizing: border-box;
}
.world .box .wall::before {content: '';position: absolute;width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;color: #fff;font-size: 7rem;
}
.world .box .wall:nth-child(1) {-webkit-transform: translateZ(100px);transform: translateZ(100px);
}
.world .box .wall:nth-child(2) {-webkit-transform: rotateX(180deg) translateZ(100px);transform: rotateX(180deg) translateZ(100px);
}
.world .box .wall:nth-child(3) {-webkit-transform: rotateX(90deg) translateZ(100px);transform: rotateX(90deg) translateZ(100px);
}
.world .box .wall:nth-child(3)::before {-webkit-transform: rotateX(180deg) rotateZ(90deg) translateZ(-1px);transform: rotateX(180deg) rotateZ(90deg) translateZ(-1px);-webkit-animation: zeroFour 4000ms -2000ms linear infinite;animation: zeroFour 4000ms -2000ms linear infinite;
}
.world .box .wall:nth-child(4) {-webkit-transform: rotateX(-90deg) translateZ(100px);transform: rotateX(-90deg) translateZ(100px);
}
.world .box .wall:nth-child(4)::before {-webkit-transform: rotateX(180deg) rotateZ(-90deg) translateZ(-1px);transform: rotateX(180deg) rotateZ(-90deg) translateZ(-1px);-webkit-animation: zeroFour 4000ms -2000ms linear infinite;animation: zeroFour 4000ms -2000ms linear infinite;
}
.world .box .wall:nth-child(5) {-webkit-transform: rotateY(90deg) translateZ(100px);transform: rotateY(90deg) translateZ(100px);
}
.world .box .wall:nth-child(5)::before {-webkit-transform: rotateX(180deg) translateZ(-1px);transform: rotateX(180deg) translateZ(-1px);-webkit-animation: zeroFour 4000ms linear infinite;animation: zeroFour 4000ms linear infinite;
}
.world .box .wall:nth-child(6) {-webkit-transform: rotateY(-90deg) translateZ(100px);transform: rotateY(-90deg) translateZ(100px);
}
.world .box .wall:nth-child(6)::before {-webkit-transform: rotateX(180deg) rotateZ(180deg) translateZ(-1px);transform: rotateX(180deg) rotateZ(180deg) translateZ(-1px);-webkit-animation: zeroFour 4000ms linear infinite;animation: zeroFour 4000ms linear infinite;
}@-webkit-keyframes zeroFour {0% {content: '4';}100% {content: '0';}
}@keyframes zeroFour {0% {content: '4';}100% {content: '0';}
}
@-webkit-keyframes roll {0% {-webkit-transform: rotateZ(0deg);transform: rotateZ(0deg);}85% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}87% {-webkit-transform: rotateZ(88deg);transform: rotateZ(88deg);}90% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}100% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}
}
@keyframes roll {0% {-webkit-transform: rotateZ(0deg);transform: rotateZ(0deg);}85% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}87% {-webkit-transform: rotateZ(88deg);transform: rotateZ(88deg);}90% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}100% {-webkit-transform: rotateZ(90deg);transform: rotateZ(90deg);}
}
@-webkit-keyframes slide {0% {-webkit-transform: translateX(0);transform: translateX(0);}100% {-webkit-transform: translateX(-200px);transform: translateX(-200px);}
}
@keyframes slide {0% {-webkit-transform: translateX(0);transform: translateX(0);}100% {-webkit-transform: translateX(-200px);transform: translateX(-200px);}
}
</style>
</head>
<body><div class="rail"><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div><div class="stamp four">4</div><div class="stamp zero">0</div>
</div>
<div class="world"><div class="forward"><div class="box"><div class="wall"></div><div class="wall"></div><div class="wall"></div><div class="wall"></div><div class="wall"></div><div class="wall"></div></div></div>
</div></body>
</html>

预览效果:
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/293373.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

虾皮跨境电商的收款方式及选择指南

虾皮&#xff08;Shopee&#xff09;作为一家知名的跨境电商平台&#xff0c;为卖家提供了多种收款方式&#xff0c;以满足不同卖家的需求。本文将介绍虾皮跨境电商平台的主要收款方式&#xff0c;并提供选择指南&#xff0c;帮助卖家根据自身需求和目标市场选择最合适的收款方…

Python (十五)pandas(三)

程序员的公众号&#xff1a;源1024&#xff0c;获取更多资料&#xff0c;无加密无套路&#xff01; 最近整理了一波电子书籍资料&#xff0c;包含《Effective Java中文版 第2版》《深入JAVA虚拟机》&#xff0c;《重构改善既有代码设计》&#xff0c;《MySQL高性能-第3版》&…

详解Java中的异常体系结构(throw,throws,try-catch,finally,自定义异常)

目录 一.异常的概念 二.异常的体系结构 三.异常的处理 异常处理思路 LBYL&#xff1a;Look Before You Leap EAFP: Its Easier to Ask Forgiveness than Permission 异常抛出throw 异常的捕获 提醒声明throws try-catch捕获处理 finally的作用 四.自定义异常类 一.异…

【Netty】编解码器

目录 Java的编解码Netty编解码器概念解码器(Decoder)编码器(Encoder)编码解码器Codec Java的编解码 编码&#xff08;Encode&#xff09;称为序列化&#xff0c; 它将对象序列化为字节数组&#xff0c;用于网络传输、数据持久化或者其它用途。 解码&#xff08;Decode&#x…

漏洞复现-大唐电信AC集中管理平台敏感信息泄漏漏洞(附漏洞检测脚本)

免责声明 文章中涉及的漏洞均已修复&#xff0c;敏感信息均已做打码处理&#xff0c;文章仅做经验分享用途&#xff0c;切勿当真&#xff0c;未授权的攻击属于非法行为&#xff01;文章中敏感信息均已做多层打马处理。传播、利用本文章所提供的信息而造成的任何直接或者间接的…

融资项目——vue之路由实现

通俗来说&#xff0c;路由就是锚点<a>的升级版。下面举一个例子来了解&#xff1a; <!DOCTYPE html> <html><head><meta charset"utf-8"><title></title></head><body><div id"list"><h1…

CSC访问学者/博士后/联培博士如何规划申请时间

申请国家留学基金委&#xff08;CSC&#xff09;公派访问学者/博士后/联合培养博士等出国项目&#xff0c;邀请函是必要条件&#xff0c;需提前准备。那么&#xff0c;何时提出申请比较合适&#xff1f;获得邀请函需要多长时间&#xff1f;根据知识人网多年的申请经验&#xff…

算法训练营Day24(回溯)

什么问题要用回溯&#xff1f; 暴力都解决不了的问题 组合、排列、切割、子集、棋盘&#xff0c;这些问题 如何理解回溯法&#xff1f; 回溯法比较抽象、困难&#xff0c;采用图形可以帮助理解&#xff0c;解决问题 解决方式&#xff1a;抽象为一个树型结构 模板 void b…

<JavaEE> 网络编程 -- 网络编程和 Socket 套接字

目录 一、网络编程的概念 1&#xff09;什么是网络编程&#xff1f; 2&#xff09;网络编程中的基本概念 1> 收发端 2> 请求和响应 3> 客户端和服务端 二、Socket套接字 1&#xff09;什么是“套接字”&#xff1f; 2&#xff09;Socket套接字的概念 3&…

CVE-2023-49898 Apache incubator-streampark 远程命令执行漏洞

项目介绍 Apache Flink 和 Apache Spark 被广泛用作下一代大数据流计算引擎。基于大量优秀经验结合最佳实践&#xff0c;我们将任务部署和运行时参数提取到配置文件中。这样&#xff0c;带有开箱即用连接器的易于使用的 RuntimeContext 将带来更轻松、更高效的任务开发体验。它…

鸿蒙系列--组件介绍之其他基础组件(上)

上回介绍了基础组件中最常用的组件常用的基础组件&#xff0c;接下来还有其他基础组件 一、Blank 描述&#xff1a;空白填充组件 功能&#xff1a;在容器主轴方向上&#xff0c;具有自动填充容器空余部分的能力。只有当父组件为Row/Column时生效 子组件&#xff1a;无 Blan…

无约束优化问题求解(3):共轭梯度法

目录 4. 共轭梯度法4.1 共轭方向4.2 共轭梯度法4.3 共轭梯度法的程序实现4.4 非二次函数的共轭梯度法 Reference 4. 共轭梯度法 4.1 共轭方向 最速下降法的线搜索采取精确线搜索时&#xff0c;由精确线搜索需要满足的条件&#xff1a;迭代点列 x k 1 x k α k d k x_{k1}…