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

290 篇文章 1 订阅
47 篇文章 0 订阅



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

在web.xml文件加入:

  1. <error-page>  
  2.    <error-code>403</error-code>  
  3.    <location>/error/403</location>  
  4. </error-page>   
  5. <error-page>  
  6.    <error-code>404</error-code>  
  7.    <location>/WEB-INF/error/404.jsp</location>  
  8. </error-page>  

自己设计的404错误页面:
  1. <%@ page language="java" contentType="text/html; charset=utf-8"  
  2.     pageEncoding="utf-8"%>  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  4. <html>  
  5. <head>  
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  7. <title>页面找不到</title>  
  8.   
  9. <style>  
  10.   
  11. body {  
  12.   background-color: #f9f9f9;  
  13.   font-size: 14px;  
  14. }  
  15.   
  16. h1 {  
  17.     font-size: 20px;  
  18.     font-weight: bold;  
  19.     margin: 0 0 20px;  
  20.     padding: 0;  
  21.     color: #444;  
  22. }  
  23.   
  24. a {  
  25.     color: #428bca;  
  26.     text-decoration: none;  
  27. }  
  28.   
  29. a:hover {  
  30.     text-decoration: underline;  
  31. }  
  32.   
  33. .container {  
  34.   width: 500px;  
  35.   margin: 60px auto;  
  36.   background: #fff;  
  37.   border: 1px solid #ddd;  
  38. }  
  39.   
  40. .content {  
  41.     padding: 40px;  
  42. }  
  43.   
  44. .message {  
  45.     margin-bottom: 20px;  
  46.     color: #666;  
  47.     line-height: 24px;  
  48. }  
  49.   
  50. .actions a {  
  51.     margin-right: 20px;  
  52. }  
  53.   
  54. </style>  
  55. </head>  
  56. <body>  
  57.     <div class="container">  
  58.         <div class="content">  
  59.             <h1>页面找不到</h1>  
  60.             <div class="message">该页面已被删除,或地址错误。</div>  
  61.             <div class="actions">  
  62.                 <a href="/index">返回首页</a>  
  63.             </div>  
  64.         </div>  
  65.     </div>  
  66. </body>  
  67. </html>  

文件位置图:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值