How to clean up a particular view in the Session

巧了我就是萌 提交于 2019-12-25 01:23:36

问题


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.


回答1:


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

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">

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.

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.



来源:https://stackoverflow.com/questions/20422001/how-to-clean-up-a-particular-view-in-the-session

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!