我使用的是JSF1.2+ Seam 2.2.1和JBossAS 4.0.4。
我在文件pages.xml中有以下条目:
<exception>
<end-conversation/>
<redirect view-id="/facelets/error.xhtml"/>
</exception>但是,如果我在会话到期后单击commandLink和commandButton,服务器会抛出以下异常:
12:19:09,671 WARN [lifecycle] executePhase(RESTORE_VIEW 1,com.sun.faces.context.FacesContextImpl@1d7187f) threw exception
javax.faces.application.ViewExpiredException: viewId:/facelets/login.xhtml - View /facelets/login.xhtml could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)同样值得注意的是,任何响应都不会返回。
我已经尝试过显式地捕获异常,但它不起作用。
有什么建议吗?
发布于 2011-05-12 22:15:54
我在搜索Seam的错误处理时发现了这一点
<\!-\- Now we specify the super class of all Exceptions: java.lang.Exception. This will catch all exceptions. \-->
<\!-\- But it will give us access to the Exception to retrieve its contents for display to the screen. \-->
<exception class="java.lang.Exception">
<\!-\- still a good idea to end the "conversation" rather than leaving it open ended. \-->
<end-conversation/>
<\!-\- now we redirect to the current page. The code for this is in the next example. \-->
<redirect view-id="#{viewId.currentValue}">
<\!-\- specify the message severity as error. Also the expression language used below allows us to "grab"-->
<\!-\- the exception that was captured above and then pass it to the h:message tag for display to the end \-->
<\!-\- user. Much nicer than a debug screen. \-->
<message severity="error">
#{org.jboss.seam.handledException.message}
</message>
</redirect>
</exception>有了这个,你实际上应该能够捕捉到所有的东西,并公开它的真实面目。viewId.currentValue是我们用来写到当前页面的一段代码,但是你可以重定向到你想要的任何地方。
发布于 2011-05-13 20:51:43
我在Seam's community site上找到了这个链接,他们正在讨论一个类似的问题。也许你的答案就在那里?它们涵盖了几种不同的解决方案,这取决于问题的根源。
发布于 2011-07-21 04:29:31
尝试在pages.xml中使用以下内容:
<exception class="javax.faces.application.ViewExpiredException">
<redirect view-id="/pages/login.xhtml">
<message severity="error">Your session has timed out, please Log-In again</message>
</redirect>
</exception>https://stackoverflow.com/questions/5977968
复制相似问题