一个项目的404错误处理页面

可以从网站上404模板,下载后进行修改即可。

  一个项目难免会出现404页面,为了防止404错误暴露给用户,需要提前做好404页面。在404页面中给用户友好的提示,同时可以自动重定向到项目的主页。

 

web.xml配置404页面

    <!-- 404页面 -->
    <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>

 

 

 

一个404页面的模板:

404.jsp  (页面中引用的图片要放到images文件夹下.页面要给处提示,同时能能将用户送回主页)

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>404</title>
<meta http-equiv="refresh" content="60;url=index.jsp">
<!-- content="600,即600秒后返回主页,可根据需要修改或者删除这段代码 -->
<link href="css/error.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- 代码 开始 -->
<div id="container"><img class="png" src="images/404.png" /> <img class="png msg" src="images/404_msg.png" />
  <p><a href="index.jsp"><img class="png" src="images/404_to_index.png" /></a> </p>
</div>
<div id="cloud" class="png"></div>
<!-- 代码 结束 -->

 
</body>
</html>

 css/error.css

/*  搜集整理 www.198zone.com */
body, div {
    margin: 0;
    padding: 0;
}
body {
    background: url("../images/error_bg.jpg") repeat-x scroll 0 0 #67ACE4;
}
#container {
    margin: 0 auto;
    padding-top: 50px;
    text-align: center;
    width: 560px;
}
#container img {
    border: medium none;
    margin-bottom: 50px;
}
#container .error {
    height: 200px;
    position: relative;
}
#container .error img {
    bottom: -50px;
    position: absolute;
    right: -50px;
}
#container .msg {
    margin-bottom: 65px;
}
#cloud {
    background: url("../images/error_cloud.png") repeat-x scroll 0 0 transparent;
    bottom: 0;
    height: 170px;
    position: absolute;
    width: 100%;
}

 

 效果:

 

 

 

注意:

修改下面代码可以修改默认跳转页面与时间。。。

<meta http-equiv="refresh" content="60;url=index.jsp">
<!-- content="600,即600秒后返回主页,可根据需要修改或者删除这段代码 -->

 

 

 

 

 

<meta http-equiv="refresh" content="60;url=index.jsp">
<!-- content="600,即600秒后返回主页,可根据需要修改或者删除这段代码 -->

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值