PF 3.5(4.0)、Omnifaces 1.6.3、Mojara 2.1.21
是否可以控制将在 JSF xhtml 页面内发送的 http header ?我的意思是:
.xhtml:
<html xmlns:http="a cool name space">
<h:head>
<http:headers header="Cache-Control" value="no-cache, no-store, must-revalidate" />
</h:head>
<h:body> .... </h:body>
</html>
最佳答案
你的意思是不指示浏览器缓存它?只需使用过滤器并将您想要的内容添加到响应标题中:
HttpServletResponse res = (HttpServletResponse) response;
if (!req.getRequestURI().startsWith(
req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources //
// (CSS/JS/Images/etc)
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
res.setDateHeader("Expires", 0); // Proxies.
}
另请参阅:
关于jsf - 如何控制 JSF 中的 http header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20263902/