在JSF页面模板中,我使用此代码包含一个CSS资源:
In JSF page templates I use this code to include a CSS resource:
<h:outputStylesheet library="css" name="mystyles.css" />实现CSS缓存清除的通常方法是添加一个版本参数,例如 v = 123 ,但outputStyleSheet不支持此类型:
The usual way to implement CSS cache busting would be to add a version parameter, like v=123, however this is not supported in outputStyleSheet:
<h:outputStylesheet library="css" name="mystyles.css?v=123" />将导致JSF1064警告,并且将找不到CSS。
will cause a JSF1064 warning and the CSS will not be found.
推荐答案这不可能不超过 StylesheetRenderer (假设你在Mojarra)。它确实不考虑查询字符串。但是,作为一个(临时)解决方法,很好地知道使用CSS自己的 @import 规则来包含CSS是有效的< h :outputStyleSheet> 。
That's not possible without overridding the StylesheetRenderer (assuming you're on Mojarra). It does indeed not take the query string into account. However, as a (temporary) workaround it's good to know that it is valid to include the CSS using CSS' own @import rule inside <h:outputStyleSheet>.
<h:outputStylesheet target="head"> @import url('css/mystyles.css?v=123') </h:outputStylesheet>您可能需要发布增强请求给Mojarra男孩,以便在未来的版本中考虑到这一点。
You might want to post an enhancement request to the Mojarra boys to take this into account in future releases.
更多推荐
如何使用JSF outputStylesheet实现CSS缓存清除?
发布评论