Jsf 2 会话通过web.xml过期后,将用户重定向到错误页(xhtml)
我的环境是:NetBeans7.2.1、GlassFish3.1、JSF2和Weld 1.1.0 当对话时间到期时,我想重定向到error.xhtml页面。 在web.xml中,我添加了以下代码:Jsf 2 会话通过web.xml过期后,将用户重定向到错误页(xhtml),jsf-2,glassfish,cdi,web.xml,weld,Jsf 2,Glassfish,Cdi,Web.xml,Weld,我的环境是:NetBeans7.2.1、GlassFish3.1、JSF2和Weld 1.1.0 当对话时间到期时,我想重定向到error.xhtml页面。 在web.xml中,我添加了以下代码: <error-page> <exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type> <location>/error.
<error-page>
<exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
<location>/error.xhtml</location>
</error-page>
当我使用名为ErrorHandler的Servlet侦听器在web.xml中使用以下代码捕获此异常时:
<error-page>
<exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
<location>/ErrorHandler</location>
</error-page>
我还尝试将位置的根目录更改为/faces/error.xhtml
,但仍然不起作用
有什么问题吗?如何从web.xml重定向到页面
谢谢,这是事先准备好的 您需要将
nocid
参数添加到URL,因为出现错误的原因是CDI正在将不存在的会话id发送到error.xhtml
页面。所以试试下面的方法
<error-page>
<exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
<location>/error.xhtml?nocid=true</location>
</error-page>
org.jboss.weld.context.NonexistentConversationException
/错误。xhtml?nocid=true
更多信息这是错误:
警告:StandardWrapperValve[Faces Servlet]:PWC1406:Servlet.service()用于Servlet Faces Servlet引发异常org.jboss.weld.context.NoexistentConversationException:weld-000321未找到id 1的要还原的会话
哇,那么我不知道,这正是nocid
param应该防止的,即使出错。xhtml
不使用对话?你知道这是什么原因吗?它似乎找不到页面,我不知道为什么。。。。。
WARNING: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
org.jboss.weld.context.NonexistentConversationException: WELD-000321 No conversation found to restore for id 1
<error-page>
<exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
<location>/error.xhtml?nocid=true</location>
</error-page>