如何设置视图超时? [英] How can I set the view timeout?

查看:156
本文介绍了如何设置视图超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JBoss 7.1.1上的 JSF2 项目中,我们在web.xml中定义了会话超时,它工作正常.

但是,有时我们会导致视图过期,即使会话仍然存在,也会导致类似这样的错误:

javax.faces.application.ViewExpiredException: viewId:/... - View /... could 
not be restored.

我们在哪里可以像在会话中那样设置查看超时?还是视图过期是由其他原因引起的?

解决方案

ViewExpiredException的另一个原因是在会话中创建了太多个逻辑视图.缺省限制是特定于JSF实现的,并且特定视图上的每个同步GET请求基本上都会创建一个新视图.因此,例如,当您使用Mojarra(默认限制为15)并启动浏览器会话并在16个不同的选项卡中打开相同的视图,然后在第一个选项卡中提交表单时,也可能会遇到此异常.该限制可以使用JSF实现特定的上下文参数进行配置,该上下文参数为 com.sun.faces.numberOfLogicalViews 用于Mojarra和 org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION 在MyFaces中(默认为20).

然而,这是一个非常罕见的现实问题.如果您的Web应用程序确实是设计用于这种方式的(例如,邀请在多个标签中打开的社交/社区网站,例如讨论论坛或Q& A),那么您可以考虑使用客户端状态保存.

另请参见:

In our JSF2 project on JBoss 7.1.1, we define a session timeout in the web.xml and it works just fine.

However, sometimes we're getting view expiration, leading to errors like this one even if the session is still alive:

javax.faces.application.ViewExpiredException: viewId:/... - View /... could 
not be restored.

Where can we set the view timeout, like we did for sessions? Or is the view expiration caused by something else?

解决方案

Another cause of ViewExpiredException is that too many logical views are been created in the session. The default limit is JSF implementation specific and every synchronous GET request on a particular view basically creates a new view. So, for example, when you use Mojarra (which has a default limit of 15) and start a browser session and open the same view in 16 different tabs and then submit a form in the 1st one, then you may get this exception as well. The limit is configureable with a JSF implementation specific context parameter, which is com.sun.faces.numberOfLogicalViews for Mojarra and org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION in MyFaces (defaults to 20).

This is however a very rare real world problem. If your webapp is really designed to be used this way (e.g. a social/community site which invites to being opened in multiple tabs, such as discussion forum or Q&A), then you might consider using client side state saving instead.

See also:

这篇关于如何设置视图超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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