如何使用JSF outputStylesheet实现CSS缓存清除?

编程入门 行业动态 更新时间:2024-10-09 08:29:01
本文介绍了如何使用JSF outputStylesheet实现CSS缓存清除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在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缓存清除?

本文发布于:2023-11-30 21:47:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651570.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   如何使用   outputStylesheet   JSF   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!