如何清理会话中的特定视图 [英] How to clean up a particular view in the Session

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

问题描述

当javax.faces.STATE_SAVING_METHOD设置为server时,每个页面的视图状态保存在会话映射中.如果我已经在某个视图中,并且如果我在浏览器中输入了URL(GET请求)到同一页面,则将创建一个新视图.现在,我要删除现有视图.如果我具有关联的ViewId包含在get请求路径中或作为GET请求参数,那么用新的GET请求清理特定的早期视图的最佳方法和位置是什么.非常感谢您的帮助.

When javax.faces.STATE_SAVING_METHOD is set to server, view state of the each page is saved in session map. If I am already in some view, and if I enter a url in browser (GET request) to the same page, a new view will be created. Now I want to delete the existing view. What is the best way and place, to clean up a particular earlier view with a new GET request, if I have the associated ViewId included in the get request path or as a GET request parameter. Thank you very much for your help.

推荐答案

您不能.至少不是通过标准的API手段.只是让它过期.

You can't. At least not by standard API means. Just let it expire.

如果由于目标服务器上的内存占用量少而担心内存使用,并且打算在无状态模式下使用JSF,并且您正在使用Mojarra 2.1.19或更高版本,请使用

If you worry about the memory usage because of a low memory footprint on target server and you intend to use JSF in stateless mode, and you're using Mojarra 2.1.19 or newer, just use

<f:view transient="true">

这样,JSF根本不会保存视图状态.请记住,逻辑上的后果是您不能再使用视图范围.视图范围的Bean的行为类似于请求范围的Bean.

This way JSF won't save the view state at all. Keep in mind that the logical consequence is that you can't use the view scope anymore. The view scoped beans will behave like request scoped beans.

另一种方法是降低会话中(逻辑)视图的默认数量.另请参见 com.sun.faces.numberOfViewsInSession与com.sun.faces.numberOfLogicalViews 才能正常工作.

An alternative is to lower the default amount of (logical) views in session. See also com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews for the exact working.

这篇关于如何清理会话中的特定视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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