jsp自定义错误页面_自定义错误页面提示-指定您希望没人看到的页面

jsp自定义错误页面

Creating custom error pages is extremely ironic in that you put great effort into pages you hope no one sees. Custom error pages are worth the effort as they:

创建自定义错误页面具有极大的讽刺意味,因为您将很大的精力放在了希望没人能看到的页面上。 自定义错误页面值得付出努力,因为它们:

  • keep a person at your site -- without the custom error page, the user sees an ugly error page.

    将人员保留在您的站点上-没有自定义错误页面,用户会看到一个难看的错误页面。
  • can be used to record the errant URL and its referrer so that you may easily fix a bad link within your own site.

    可用于记录错误的网址及其引荐来源网址,以便您可以轻松修复自己网站中的错误链接。
  • show professionalism in that you tend to every possible output of your website.

    显示专业精神,因为您倾向于网站的所有可能输出。
  • prevent most users from recognizing a problem with your site and thus your website maintains credibility.

    阻止大多数用户识别您的网站问题,从而使您的网站保持信誉。

There are 5 main error pages you should create:

您应该创建5个主要错误页面:

  • 400 - Bad Request

    400-错误的请求
  • 401 - Authorization Required

    401-需要授权
  • 403 - Forbidden

    403-禁止
  • 404 - File Not Found

    404-找不到文件
  • 500 - Internal Server Error

    500内部服务器错误

Once you have your pages ready, you'll need to add one line of code per error page to your .htaccess file.

准备好页面后,需要在每个错误页面上向.htaccess文件添加一行代码。

代码 (The Code)

ErrorDocument 400 /bad-request.php
ErrorDocument 401 /authorization-required.php
ErrorDocument 403 /forbidden.php
ErrorDocument 404 /page-not-found.php
ErrorDocument 500 /internal-server-error.php

The ErrorDocument directive allows you to tell the server which page will be called when the respective error number occurs.

ErrorDocument指令允许您告诉服务器在发生相应的错误号时将调用哪个页面。

处理错误页面的提示 (Tips For Handling Error Pages)

  • Know your audience before judging whether to let the user know the page they were looking for wasn't found. A Web Developer will want to know that a page wasn't found, whereas an average web user may lose respect for your site...or visa versa.

    在判断是否让用户知道他们要查找的页面之前,先了解您的受众。 Web开发人员将想知道未找到页面,而普通的Web用户可能会失去对您网站的尊重...反之亦然。
  • Keep them light & funny but maintain professionalism.

    让他们保持轻松有趣,但保持专业水平。
  • Keep them within the same theme of your website or at least have your navigation menu on the error page -- it allows users to navigate to other parts of your website. You don't want users to just hit the back button, right?

    将它们保持在您网站的同一主题内,或者至少在错误页面上显示您的导航菜单-允许用户导航到您网站的其他部分。 您不希望用户仅单击“后退”按钮,对吧?
  • Use each page to record the errant URL and referrer so that you can identify bad links.

    使用每个页面记录错误的URL和引荐来源网址,以便您识别错误的链接。

翻译自: https://davidwalsh.name/custom-404-page-tips

jsp自定义错误页面

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值