viewExpiredException JSF

时间:2010-01-22 00:12:33

标签: java session jsf viewexpiredexception

要在JSF中处理viewExpiredException,我编码了

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/error.html</location>
</error-page>

<session-config>
    <session-timeout>1</session-timeout>
</session-config>
web.xml中的

error.html我已重定向到原始登录页面。但问题是会话范围bean即使会话过期也没有被清除。有什么方法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:7)

可能已从浏览器缓存请求登录页面。通过创建与Filter绑定的FacesServlet来禁用它,并且在doFilter()方法中基本上有以下几行,这样您就不需要在所有页面上重复它我希望防止被缓存。

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