Internet Explorer中不显示自定义HTTP错误页面

gor*_*613 8 internet-explorer jsp custom-error-pages

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

我所做的是声明自定义错误页面如下web.xml:

<error-page>
  <error-code>500</error-code>
  <location>/error.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

我创建了一个error.jsp使用以下代码调用的JSP :

<%@ 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>
Run Code Online (Sandbox Code Playgroud)

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

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

Bal*_*usC 24

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

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