Internet Explorer中不显示自定义HTTP错误页面 [英] Custom HTTP error page is not displayed in Internet Explorer

查看:176
本文介绍了Internet Explorer中不显示自定义HTTP错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Tomcat 7和JSP页面。我想为HTTP 500错误提供自定义错误页面。

I am using Tomcat 7 and JSP pages. I would like to provide a custom error page for HTTP 500 errors.

我所做的是在 web中声明自定义错误页面,如下所示。 xml

<error-page>
  <error-code>500</error-code>
  <location>/error.jsp</location>
</error-page>

我创建了一个名为的错误错误.jsp 使用以下代码:

And I created a JSP called error.jsp with the following code:

<%@ page pageEncoding="UTF-8" isErrorPage="true" %>
<!DOCTYPE html>
<html>
  <head>
    <title>500</title>
  </head>
  <body>
    <img src="${pageContext.request.contextPath}/images/500.jpg" />
  </body>
</html>

现在这适用于大多数浏览器,但在Internet Explorer中我被带到标准网站不能显示页面页面。

Now this works in most browsers, but in Internet Explorer I am taken to the standard "The website cannot display the page" page.

为什么我的自定义HTTP 500错误页面没有显示在Internet Explorer中?

Why is my custom HTTP 500 error page not being displayed in Internet Explorer?

推荐答案

这是一个IE功能。当从服务器检索的HTTP错误页面小于512字节时,默认情况下IE将显示友好错误页面,如您所面临的错误页面,可由工具> Internet选项>高级>取消选中浏览器中显示显示友好错误消息。其他(真实)浏览器没有此功能。

This is an IE feature. When an HTTP error page retrieved from the server is smaller than 512 bytes, then IE will by default show a "Friendly" error page like the one you're facing, which is configureable by Tools > Internet Options > Advanced > Uncheck "Show Friendly Error Message" in the browser. Other (real) browsers does not have this feature.

使您的HTTP错误页面大于512字节应解决此IE功能。您可以添加一些额外的元标题,在缩进代码中添加一些空格,在网站的标准布局后添加更多语义标记,添加大型HTML注释等。

Making your HTTP error page a little larger than 512 bytes should workaround this IE feature. You could add some extra meta headers, add some whitespace to indent code, add some more semantic markup following your site's standard layout, add a large HTML comment, etc.

这篇关于Internet Explorer中不显示自定义HTTP错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆