链接损坏重定向到自己设计的404错误页面


不存在的链接重定向到自己设计的404错误页面

在web.xml文件加入:

    <error-page>
       <error-code>403</error-code>
       <location>/error/403</location>
    </error-page> 
    <error-page>
       <error-code>404</error-code>
       <location>/WEB-INF/error/404.jsp</location>
    </error-page>

自己设计的404错误页面:

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>页面找不到</title>

<style>

body {
  background-color: #f9f9f9;
  font-size: 14px;
}

h1 {
	font-size: 20px;
	font-weight: bold;
	margin: 0 0 20px;
	padding: 0;
	color: #444;
}

a {
	color: #428bca;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

.container {
  width: 500px;
  margin: 60px auto;
  background: #fff;
  border: 1px solid #ddd;
}

.content {
	padding: 40px;
}

.message {
	margin-bottom: 20px;
	color: #666;
	line-height: 24px;
}

.actions a {
	margin-right: 20px;
}

</style>
</head>
<body>
	<div class="container">
		<div class="content">
			<h1>页面找不到</h1>
			<div class="message">该页面已被删除,或地址错误。</div>
			<div class="actions">
				<a href="/index">返回首页</a>
			</div>
		</div>
	</div>
</body>
</html>

文件位置图:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值