您的位置:首页 > 其它

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

2013-12-04 15:46 176 查看
不存在的链接重定向到自己设计的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>


文件位置图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐