gpt4 book ai didi

javax.faces.application.ViewExpiredException 看似被忽略

转载 作者:行者123 更新时间:2023-11-29 06:17:01 29 4
gpt4 key购买 nike

我已将以下内容放入我的 web.xml 中:

    <error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/expiredIndex.jsf</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error.jsf</location>
</error-page>
<session-config>
<session-timeout>1</session-timeout>
</session-config>

当我启动我的应用程序并等待 1 分钟时,如果我随后尝试与其交互(JSF 1.2,h:commandButton),我会收到错误

 SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)

有人能告诉我为什么 javax.faces.application.ViewExpiredException 没有被提取吗?我正在寻找可能的最基本的到期设置,并且肯定这就是网络描述符中所必需的。

谢谢

编辑

现在我的 web.xml 中有以下内容:

<filter>
<filter-name>Error</filter-name>
<filter-class>myClient.ErrorFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>Error</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<error-page>
<exception-type>javax.servlet.ViewExpiredException</exception-type>
<location>/expiredIndex.jsf</location>
</error-page>

(这些条目是 web.xml 中的最后一个过滤器条目)和一个使用 doFilter 方法的新过滤器,如 this 中所述。邮政。现在应该发生的是 rootCause 应该解包 ViewExpiredException,这样当 servlet session 超时时应该将用户重定向到我的 expiredIndex 页面。相反,我得到了 500。在这种情况下,我看不出还需要做什么才能进行正确的重定向。帮助!

编辑 2

500 的错误是:

javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
prismClient.ErrorFilter.doFilter(Unknown Source)

我想这是标准的。

最佳答案

这是因为 ViewExpiredException - 与所有其他 FacesException 一样 - 在幕后被包裹在 ServletException 中。这个用于在声明的错误页面中查找匹配项。最接近的匹配项是 java.lang.Throwable,因此会显示关联的错误页面。

如果未找到匹配项,则 ServletException 的根本原因将被解包,并且将对已解包的异常进行第二次遍历声明的错误页面。如果删除 java.lang.Throwable 条目,您会发现这会起作用。

如果你想保留 java.lang.Throwable,那么你最好做的就是创建一个 Filter 来解包任何 FacesException 来自 ServletException 并重新抛出它。

另见:

关于javax.faces.application.ViewExpiredException 看似被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4716030/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com