JSF clearing messages
<h:messages class="loginFailed" globalOnly="true" layout="table" />
I have thi开发者_如何学JAVAs at the bottom of my login page. When the user fails to login it displays an error message. My problem is when they navigate to the registration page the error message is still there.
How do I get rid of this message.
It's definitely a browser cache issue. The pages are requested from the browser cache when navigating using the back button. I investigated the response headers on the site link you provided using Firebug and they indeed don't contain headers which instructs the browser to not cache the page.
Create a Filter
which is mapped on an URL pattern of *.xhtml
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);
精彩评论