我有两个错误页面; 1表示SpecificExceptionA,另一个表示Throwable.
<error-page>
<exception-type>org.SpecificExceptionA</exception-type>
<location>/WEB-INF/views/error/timedout.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/error/error.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
如果我在web.xml中定义了这两个,那么一切都转到/error/error.jsp.
如果我只定义了特定的异常,它将转到正确的页面; 但其他错误转到tomcat默认值(404除外)
有没有更好的方法来指定特定的异常处理程序?我正在使用spring 3.0.
如何在网络出错时自定义Google Chrome/Chromium显示的错误页面(例如错误137 net :: ERR_NAME_RESOLUTION_FAILED)
我在谈论这些页面:http://i41.tinypic.com/29qm8v6.png
它们似乎不存储在文件系统的任何位置.可以使用扩展程序捕获使它们显示的错误吗?
谢谢你的建议.
这是上下文:
我为一家非常大的企业工作.在这里,我们有许多WebSphere Application Server集群,每个集群都运行许多Java EE Web应用程序.这些应用程序中的大多数(但不是全部)在其web.xml中包含特殊指令,以便在发生意外异常时显示自定义错误页面.这是一个例子:
<error-page>
<error-code>500</error-code>
<location>/500.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
当然,通过这样做,我们的目标是向客户显示一个友好的错误页面,而且,我们主要的目的是隐藏通常包含在标准http 500错误页面中的堆栈跟踪.
正如您应该知道的,这些堆栈跟踪包含许多敏感数据,例如包的名称,类的名称甚至方法的名称.有时,最糟糕的是,这些堆栈跟踪包含SQL异常,这些异常通常会显示使用哪些数据库服务器软件.甚至最糟糕的是,这些堆栈跟踪包含文件和文件夹路径,这反过来可以揭示我们的WebSphere Application Server运行在哪个操作系统的系列上.
我是否需要提及这些堆栈跟踪可以揭示的所有其他更敏感的数据?(用户名,端口号,IP地址,计算机/服务器名称,JNDI对象的名称......)
因此,这里没有什么大惊喜,每个大型企业都需要将这些堆栈跟踪隐藏到客户手中.
但是,这是我们的问题:
有时,即使在web.xml文件中配置了自定义错误页面,WebSphere也会将基本错误页面发送到客户的Web浏览器.我非常理解为什么WebSphere会这样做.例如,我知道当http响应的头已经提交时,WebSphere无法重置其缓冲区以发送自定义错误页面,然后无法比发送基本错误页面做得更好.
这是我的问题:
(1)是否可以配置WebSphere,以便它的基本错误页面中永远不会包含任何堆栈跟踪?这样,即使由于某些技术原因,WebSphere无法发送我们的自定义错误页面,至少基本错误页面也不会包含任何敏感数据.
我们应该怎么做?
谢谢,
java websphere stack-trace production-environment custom-error-pages
为什么这不起作用
handler500 = TemplateView.as_view(template_name="500.html")
Run Code Online (Sandbox Code Playgroud)
我得到以下异常:
Traceback (most recent call last):
File "/usr/lib/python2.6/wsgiref/handlers.py", line 94, in run
self.finish_response()
File "/usr/lib/python2.6/wsgiref/handlers.py", line 134, in finish_response
for data in self.result:
File "/home/hatem/projects/leadsift_app/.virtualenv/lib/python2.6/site-packages/django/template/response.py", line 117, in __iter__
raise ContentNotRenderedError('The response content must be 'ContentNotRenderedError: The response content must be rendered before it can be iterated over.
Run Code Online (Sandbox Code Playgroud)
我发现这组笔记描述了你在脚下射击自己使用基于类的视图,为什么会这样?
编辑:我最终使用了这个...但我仍然希望那里有人会告诉我如何获得原始的oneliner或类似的工作
class Handler500(TemplateView):
template_name = "500.html"
@classmethod
def as_error_view(cls):
v = cls.as_view()
def view(request):
r = v(request)
r.render()
return r
return view
handler500 = Handler500.as_error_view()
Run Code Online (Sandbox Code Playgroud) 有没有办法为nginx error_pages设置绝对路径?不是绝对的http://,而是绝对的/usr/var/nginx/errors/500.html.
configuration webserver nginx absolute-path custom-error-pages
我正在尝试创建一些自定义错误页面,但似乎无法使500工作.
我有以下配置:
server {
listen 80;
root /var/www/devsite;
index index.php;
server_name devsite;
error_page 403 = /error.php?code=403;
error_page 404 = /error.php?code=404;
error_page 500 = /error.php?code=500;
location / {
try_files $uri =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
起初,我认为这可能是因为它是一个PHP文件所以我改变了:
error_page 500 = /error.php?code=500;
Run Code Online (Sandbox Code Playgroud)
到静态页面:
error_page 500 /500.html
Run Code Online (Sandbox Code Playgroud)
但是当我打破一些PHP代码来触发它时,它仍然只显示一个带有500响应代码的空白页面.
然后我试着让它成为里面的最后一条规则,location ~ \.php$但同样的事情发生了.任何想法为什么自定义500页不起作用?
我还注意到,如果您尝试访问具有.php扩展名的"访问被拒绝"文件,它将不会显示自定义403页面并显示内置页面.有没有办法让规则覆盖.php文件呢?
我正在尝试使用自定义错误页面返回404状态代码.但是我继续得到200,因为只要浏览器和服务器可以告诉页面确实存在.
到目前为止我一直在尝试的是:
<customErrors mode="On" defaultRedirect="~/404" >
<error statusCode="404" redirect="~/404"/>
</customErrors>
Run Code Online (Sandbox Code Playgroud)
其中404是指向"未找到页面"控制器和操作的路径.
我也尝试在我的动作中设置状态代码..
public ActionResult PageNotFound(string locale)
{
Response.StatusCode = 404;
return View();
}
Run Code Online (Sandbox Code Playgroud)
但这最终只会显示默认的服务器错误页面(灰色的一个带有红色错误消息文本)
有关如何解决这个问题的任何想法?
我试图让我的Web服务器已自定义错误文档/页,但与 PHP代码包含在其中,而不会重新导向它们已抛出错误的页面了.
假设我们正在导航http://website.com/pages/1并且它是抛出错误500,默认情况下页面只是一个空白的白页,文本" Error 500 (Internal Server Error)"看起来像这样:
正如您从上面所看到的,它没有重定向远离抛出错误的页面.我希望此页面看起来是"网站的一部分",但其中包含PHP内容.
我不能通过编辑您在下面看到的页面在cPanel中的错误页面中包含PHP内容:
如果我要编辑上面的错误500页,下面的内容http://website.com/pages/1将会重定向到http://website.com/500.shtml然后重定向到 http://website.com/500.php
我不希望它重定向,否则它意味着刷新页面本质上只会刷新500.php页面而不是刷新/pages/1
<script language="javascript">
window.location.href = "http://www.website.com/500.php"
</script>
<meta http-equiv="refresh" content="0;URL='http://website.com/500.php'" />
Run Code Online (Sandbox Code Playgroud)
同样存在同样的问题,只是没有2链重定向,而只是在.htaccess文件中使用以下内容进行重定向.
ErrorDocument 400 http://website.com/400.php
ErrorDocument 401 http://website.com/401.php
ErrorDocument 403 http://website.com/403.php
ErrorDocument 404 http://website.com/404.php
ErrorDocument 500 http://website.com/500.php
Run Code Online (Sandbox Code Playgroud)
当前结果:重定向到/500.php
预期结果:在http://website.com/pages/1上/中显示500.php 而不重定向
有没有办法通过root做到这一点(我可以让我的主机做某事,如果有的话?)
我正在寻找第一次使用ELMAH,但是需要满足我不确定如何实现的要求......
基本上,我将配置ELMAH在asp.net MVC下工作,并让它在发生错误时将错误记录到数据库中.除此之外,我将使用customErrors在发生错误时将用户定向到友好的消息页面.相当标准的东西......
要求是在这个自定义错误页面上我有一个表单,使用户可以根据需要提供额外的信息.现在问题出现的原因是此时已经记录了错误,我需要将漏洞错误与用户反馈相关联.
通常,如果我使用自己的自定义实现,在记录错误后,我会将错误的ID传递给自定义错误页面,以便可以建立关联.但由于ELMAH的工作方式,我不认为这是可能的.
因此我想知道人们怎么会想到这样做......
干杯
更新:
我对这个问题的解决方案如下:
public class UserCurrentConextUsingWebContext : IUserCurrentConext
{
private const string _StoredExceptionName = "System.StoredException.";
private const string _StoredExceptionIdName = "System.StoredExceptionId.";
public virtual string UniqueAddress
{
get { return HttpContext.Current.Request.UserHostAddress; }
}
public Exception StoredException
{
get { return HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] as Exception; }
set { HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] = value; }
}
public string StoredExceptionId
{
get { return HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] as string; }
set { HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] = value; …Run Code Online (Sandbox Code Playgroud) 我正在使用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中显示?