JSF 捕获 ViewExpiredException 时重定向错误
所以我有一个 ViewExpiredException 处理程序并且工作正常。 现在,当我启动网络应用程序时,我的 URL 看起来像 www.myApp.com/TestFaces/
,这会显示第一页,即登录页面。 如果出于任何原因我在登录时离开页面,并且视图过期,应用程序会捕获 ViewExpiredException 并将我发送到页面“ViewExpired”,但 URL 保持不变 www.myApp.com/TestFaces/
。在“ViewExpired”页面上,我有一个命令链接返回到登录页面,在值属性中我放置了“index.xhtml”,但它不会将我发送到登录页面,因为 www.myApp 上没有页面。 com/TestFaces/index.xhtml
但在 www.myApp.com/TestFaces/faces/index.xhtml
所以问题是:
- 为什么如果我在登录页面,我会得到查看过期异常?是因为ajax吗?
- 如何或在哪里可以使 commandLink 真正将我发送到 index.xhtml?
这种情况仅发生在登录页面中的视图过期时,在我的应用程序的其他页面中,它的效果非常好。
提前致谢 !
So I have a ViewExpiredException Handler and works fine.
Now, when I launch the web-app my URL looks like www.myApp.com/TestFaces/
and this presents the first page which is the login page.
If for any reason I leave the page at login, and the View expires the app catches the ViewExpiredException and sends me to a page "ViewExpired" BUT the URL keeps the same www.myApp.com/TestFaces/
. On that "ViewExpired" page I have a commandLink to return to the login page which in the value attrib I put "index.xhtml" BUT it does not send me to login page because on there's no page on www.myApp.com/TestFaces/index.xhtml
but in www.myApp.com/TestFaces/faces/index.xhtml
So the questions are:
- Why if I'm at login page am I getting the ViewExpiredException? is it because of ajax?
- How or Where can I make the commandLink really sends me to index.xhtml?
This is only happening when the View expires in login page, in other pages from my app it works really great.
Thanks in advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你对会话中不再存在的视图调用POST请求时,你会得到这个异常。例如,当您将页面打开的时间太长以至于服务器端的会话已过期,或者当您从浏览器缓存而不是直接从服务器获取登录页面时,就会发生这种情况。有关更多详细信息,另请参阅我们的
ViewExpiredException
标记信息页面。所有 JSF ajax 请求也在此考虑,因为它们也使用 POST。使用隐式导航。这样 JSF 将附加正确的 FacesServlet 映射。
或者,
或者,更好的是,当您根本不需要调用任何业务逻辑时:
另请参阅:
You will get this exception when you invoke a POST request on a view which does not exist in session anymore. This can for example happen when you keep the page open for too long that the session has expired in the server side, or when you're getting the login page from the browser cache instead of straight from the server. For more detail, see also our
ViewExpiredException
tag info page. All JSF ajax requests also accounts in this as they also use POST.Make use of implicit navigation. This way JSF will append the proper
FacesServlet
mapping.or
or, better, when you don't need to invoke any business logic at all:
See also: