【发布时间】:2013-04-05 21:59:49
【问题描述】:
伙计们,我正在努力解决在 Windows 环境中在 Tomcat 中打开我的自定义错误页面的问题。我得到了一些解决方案,但没有运气。我尝试了几乎所有链接,但它对我不起作用。其中一些适用于部署在 Tomcat 中的其他解决方案,但不适用于我的 Web 服务
我的 web.xml
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<location>/error.html</location>
</error-page>
我从我的 Servlet 3.0 应用程序发送错误
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
我已将我的 error.html 放在我的 WebService 的根目录中。
我为 JSP 页面而不是我也尝试过的 HTML 获得的一些链接
在 JSP 的情况下,我使用了:
<%@ page isErrorPage="true" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Error</h1>
</body>
</html>
仅供参考,它适用于其他 Tomcat 内置解决方案,它运行良好。但在我的 Webservice 中,我收到响应 500,但页面打开为空白。还有一件事我禁用了我的 Internet Explorer 9.0 显示错误友好页面仍然响应来自 servlet 的 500。但是错误页面是空的。
如果对我的查询有任何想法或疑问,请告诉我。我需要尽快。
【问题讨论】:
-
为什么发生错误时 Web 服务会尝试提供 HTML 页面?
-
...您的 servlet 和 JSP 与 Web 服务有什么关系?你确定你知道什么是网络服务?
-
因为我们在项目中使用了自定义错误页面
-
是的,我知道 servlet 使用什么 web 服务将所有输出发送到浏览器以下载图像和 jsp 页面/html 页面我想清楚地显示我的自定义错误页面?
-
@SumitSharma 我遇到了与您描述的问题类似的问题 - Tomcat 正在打印与我在
web.xml中指定的错误页面不同的错误页面。你解决问题了吗?