我在浏览器中显示此错误消息并且页面停止响应:
core.js.xhtml?ln=primefaces&v=6.0:3 Uncaught TypeError: Cannot read property 'getElementsByTagName' of undefined
似乎这个Tomcat或JSF正在缓存POST请求!
我尝试move css on the bottom on the page - 它没有帮助。
答案 0 :(得分:0)
我所做的是设置特殊的阶段监听器来强制浏览器使缓存无效:
<强>面-config.xml中强>
<lifecycle>
<phase-listener id="nocache">com.xxxx.jsf.util.CacheControlPhaseListener</phase-listener>
<phase-listener>org.primefaces.component.lifecycle.LifecyclePhaseListener</phase-listener>
<phase-listener>com.xxxx.jsf.listeners.BackButtonPhaseListener</phase-listener>
</lifecycle>
<强>类:强>
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletResponse;
public class CacheControlPhaseListener implements PhaseListener {
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
public void afterPhase(PhaseEvent event) {
}
public void beforePhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache");
// Stronger according to blog comment below that references HTTP spec
response.addHeader("Cache-Control", "no-store");
response.addHeader("Cache-Control", "must-revalidate");
// some date in the past
response.addHeader("Expires", "Mon, 8 Aug 2006 10:00:00 GMT");
}
}