简体   繁体   English

没有重定向到web.xml中指定的页面

[英]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.

相关问题 在jsf中,会话超时后将web.xml配置重定向到登录页面 - web.xml configuration to redirect to login page after session timeout in jsf 正在处理的页面仅在错误/异常中途留空,而不是转发到web.xml中指定的错误页面 - Pages being processed are merely left blank half way through on errors/exceptions instead of forwarding to the error page specified in web.xml JSF:如何将参数传播到web.xml中的登录页面 - JSF: How to propagate params to login page in web.xml 如果FileNotFoundException,则web.xml错误页面不起作用 - web.xml error page does not work in case of FileNotFoundException 针对JSF应用程序的web.xml中的错误页面配置 - Error Page configuration in web.xml for JSF application 使用web.xml和pretty-faces重定向到自定义错误页面 - Redirecting to custom error page with web.xml and pretty-faces 具有Web.xml的JSF库 - Jsf library with web.xml 从 web.xml 中删除 FacesServlet 后,带有 .jsf 扩展名的 URL 仍重定向到 .xhtml - URLs with .jsf extension still redirect to .xhtml after FacesServlet removal from web.xml 在 web.xml 中的 java.lang.Throwable 错误页面中显示的 ViewExpiredException - ViewExpiredException shown in java.lang.Throwable error-page in web.xml 如何在没有web.xml的Java EE 7环境中运行JSF 2.2页面? - How to run a JSF 2.2 page in Java EE 7 environment without web.xml?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM