JSF-即使退出应用程序后,我的backbean的字段也不会被清除 [英] JSF - Fields of my backbean are not cleaned even after exiting the application

查看:118
本文介绍了JSF-即使退出应用程序后,我的backbean的字段也不会被清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JSF的初学者,遇到以下问题:我有一个带backbean的视图,该视图填充了一些值以执行搜索和显示结果.当我外出并返回应用程序时,最新请求中的值仍保留在其中.我在bean中使用以下注释:

I'm a beginner in JSF and I´m having the following problem: I have a view with a backbean that I fill some values ​​to perform a search and display results. When I go out and return the application, the values ​​from the latest request remain there. I use the following annotations in my bean:

@Component("requestBeneficioCustosController")
@ManagedBean(name = "requestBeneficioCustosController")
@RequestScoped
public class RequestBeneficioCustosController implements Serializable {
...

我认为使用@RequestScoped批注,离开页面后将清除Bean的值.这样行不通吗?你能帮我吗?

I thought with the @RequestScoped annotation, the values of the bean would be cleaned after leaving the page. Does not work that way? Can you help me?

提前谢谢

推荐答案

您可能会遇到来自浏览器缓存的页面.您需要指示浏览器不要缓存JSF页面.最好通过Filter来实现,该Filter映射到感兴趣的URL模式(例如*.jsf),并在doFilter()方法中完成以下工作.

You're likely facing a page from the browser cache. You need to instruct the browser to not cache the JSF pages. This is the best to be achieved by a Filter which is mapped on an URL pattern of interest (*.jsf for example) and does the following job in doFilter() method.

HttpServletResponse hsr = (HttpServletResponse) response;
hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
hsr.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);

这篇关于JSF-即使退出应用程序后,我的backbean的字段也不会被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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