如何解决 JSF 1.2 中的 ViewExpiredException
我有一个使用 JSF1.2 + Richfaces 3.3.3 Final、MyFaces 1.2.7、Spring + Hibernate 的应用程序,每次清除浏览器的缓存和 cookie 并再次登录我的应用程序时,都会出现以下异常。
javax.faces.application.ViewExpiredException - /app/project/index.jsf
找不到视图标识符的已保存视图状态:/app/project/index.jsf
谁能让我知道如何解决上述异常?
I have an application using JSF1.2 + Richfaces 3.3.3 Final, MyFaces 1.2.7, Spring + Hibernate and I get the below exception everytime when I clear the cache and cookies of the browser and login again to my application.
javax.faces.application.ViewExpiredException - /app/project/index.jsf
No saved view state could be found for the view identifier: /app/project/index.jsf
Can anyone let me know how to solve above exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将状态保存方法设置为
client
而不是server
来解决此问题,以便将视图存储(当然以序列化形式)在 POST 的隐藏输入字段中表单中,而不是在服务器端的会话中(这又由 JSESSIONID cookie 引用;因此,当您删除会话 cookie 或会话过期时,所有视图基本上都会丢失)。您可以通过将以下上下文参数添加到web.xml
中来做到这一点:如果由于某种原因上述内容不是一个选项,那么您可以做的最好的事情就是将其作为错误页面温和地处理
web.xml
如下:这并不能解决异常,但它至少为您提供了在错误页面中告诉最终用户有关问题以及应采取哪些操作的机会最终用户必须采取。您甚至可以让错误页面指向登录页面,并有条件地呈现一些有关最终用户为何再次面对登录页面的消息。
另请参阅:
ViewExpiredException
标签 wiki 页面You can solve it by setting the state saving method to
client
instead ofserver
so that views are stored (in serialized form, of course) in a hidden input field of the POST form, instead of in the session in the server side (which is in turn to be referenced byJSESSIONID
cookie; so all views will basically get lost when you delete the session cookie or when the session expires). You can do that by adding the following context parameter to theweb.xml
:If the above is not an option for some reason, then best what you could do is to handle it gently as an error page in
web.xml
as follows:This does not solve the exception, but it at least offers you the opportunity to tell in the error page the enduser about the problem and what actions the enduser has to take. You could even let the error page point to the login page and conditionally render some message about why the enduser is facing the login page again.
See also:
ViewExpiredException
tag wiki page