[英]no redirect to page specified in web.xml
in my JSF application whenever an exception occurs, it should display a JSF page, which I designed to show the user that an error occurred, but no such thing happens, that's the big problem. 在我的JSF应用程序中,每当发生异常时,它应该显示一个JSF页面,我设计该页面向用户显示发生了错误,但是没有发生这种情况,这是一个大问题。
Part of my web.xml 我的web.xml的一部分
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/faces/error.jsf</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/faces/error.jsf</location>
</error-page>
That can happen when the exception occurs during an ajax request, or when the exception occurs when the response has already been committed. 在ajax请求期间发生异常时,或者在响应已提交时发生异常时,可能会发生这种情况。
Exceptions on ajax requests needs to be handled by a custom ExceptionHandler
. ajax请求的异常需要由自定义
ExceptionHandler
处理。 OmniFaces has such one, the FullAjaxExceptionHandler
which utilizes standard Servlet API error page mechanism. OmniFaces有一个
FullAjaxExceptionHandler
,它使用标准的Servlet API错误页面机制。
Exceptions while the response is committed cannot be handled because a part of the response has already been sent to the client which is a point of no return. 无法处理响应提交时的异常,因为响应的一部分已经发送到客户端,这是一个不可逆转的点。 It can only be avoided by increasing the response buffer size by the following context parameter in
web.xml
: 只能通过
web.xml
的以下上下文参数增加响应缓冲区大小来避免它:
<context-param>
<param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name>
<param-value>65535</param-value>
</context-param>
The above example sets it to 64KB, it should be about the size of your largest page. 上面的示例将其设置为64KB,它应该是您最大页面的大小。 This way the response won't be committed until the size reaches 64KB or when it's finished.
这样,在大小达到64KB或完成时,响应将不会被提交。 This way the container will be able to change the response to the error page when an exception occurs.
这样,容器将能够在发生异常时更改对错误页面的响应。
Unrelated to the concrete problem, you've by the way an overlap in the error page configuration there. 与具体问题无关 ,您可以在错误页面配置中重叠。 Exceptions are implicitly always status 500 and you're pointing to the same error page.
异常隐式地始终为状态500,并且您指向相同的错误页面。 So the error page one with
java.lang.Exception
is superflous. 所以带有
java.lang.Exception
的错误页面1是超级的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.