Jsf 如何为不存在的ConversationException配置错误页位置?

Jsf 如何为不存在的ConversationException配置错误页位置?,jsf,cdi,custom-error-pages,weld,conversation-scope,Jsf,Cdi,Custom Error Pages,Weld,Conversation Scope,当URL中有?cid=XX时,我需要帮助处理过期/不存在的对话。我试着把 <error-page> <exception-type>org.jboss.weld.context.ContextNotActiveException</exception-type> <location>/faces/index.xhtml</location> </error-page> <error-page>

当URL中有
?cid=XX
时,我需要帮助处理过期/不存在的对话。我试着把

<error-page>
    <exception-type>org.jboss.weld.context.ContextNotActiveException</exception-type>
    <location>/faces/index.xhtml</location>
</error-page>
<error-page>
    <exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
    <location>/faces/index.xhtml</location>
</error-page>

org.jboss.weld.context.contextNotActivieException
/faces/index.xhtml
org.jboss.weld.context.NonexistentConversationException
/faces/index.xhtml

然而,这些都不起作用。我仍然收到错误,无法转发到
index.xhtml
。如何解决此问题?

您必须明确指定不应为特定请求传播对话。在index.xhtml的末尾添加
nocid=true
作为参数

<error-page>
    <exception-type>org.jboss.weld.context.NonexistentConversationException</exception-type>
    <location>/faces/index.xhtml?nocid=true</location>
</error-page>

org.jboss.weld.context.NonexistentConversationException
/faces/index.xhtml?nocid=true
请参阅以下链接

焊接异常的取消程序在web.xml中工作:

<error-page>
    <exception-type>javax.enterprise.context.NonexistentConversationException</exception-type>
    <location>/index.xhtml?nocid=true</location>
</error-page>

javax.enterprise.context.NonexistentConversationException
/index.xhtml?nocid=true

这适用于Wildfly 12和13。如果您使用的是Wildfly 10或11,则应选择异常类型“org.jboss.weld.context.NonexistentConversationException”。