如何解决JSF 1.2中的ViewExpiredException [英] How to solve ViewExpiredException in JSF 1.2

查看:142
本文介绍了如何解决JSF 1.2中的ViewExpiredException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用JSF1.2 + Richfaces 3.3.3 Final,MyFaces 1.2.7,Spring + Hibernate的应用程序,每次清除浏览器的缓存和cookie并再次登录到我的应用程序时,都会收到以下异常.

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
找不到视图标识符的已保存视图状态:/app/project/index.jsf

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?

推荐答案

您可以通过将状态保存方法设置为client而不是server来解决此问题,以便将视图存储(当然以序列化形式)在POST表单的隐藏输入字段,而不是服务器端会话中的输入字段(依次由JSESSIONID cookie引用;因此​​,当删除会话cookie或会话过期时,所有视图基本上都会丢失).您可以通过将以下上下文参数添加到web.xml来做到这一点:

You can solve it by setting the state saving method to client instead of server 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 by JSESSIONID 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 the web.xml:

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

如果由于某种原因上述选项不可行,那么最好的办法是将其作为web.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:

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/errors/sessionexpired.jsf</location>
</error-page>

这不会解决异常,但它至少使您有机会在错误页面中告知最终用户有关问题以及最终用户必须采取的措施.您甚至可以让错误页面指向登录页面,并有条件地呈现一些有关最终用户为何再次面对登录页面的消息.

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.

  • Our ViewExpiredException tag wiki page
  • javax.faces.application.ViewExpiredException: View could not be restored - for JSF 2.x

这篇关于如何解决JSF 1.2中的ViewExpiredException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆