带 CDN 的 JSF 2 资源?

发布于 2024-12-14 23:48:28 字数 137 浏览 1 评论 0原文

据我了解,JSF 2 资源的需求是帮助组织资源目录,并添加一些版本控制和本地化。

但是否可以将此功能与 CDN 结合起来?我以前从未使用过 CDN,但它看起来不错,并且想听听您对它的想法以及与 JSF 2 资源的可能组合,尽管我认为这不太可能。

As i understand it, the needs for JSF 2 resources is to help organizing resources directories, and add some versioning and localization.

But is it possible to combine this feature with a CDN ? I've never used CDN before, but it looks good, and would like to hear your ideas about it and possible combinations with JSF 2 resources, although i dont think it's likely.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

说好的呢 2024-12-21 23:48:28

对于 来说这是不可能的,因为它们只能指向 webapp 自己的资源,而不能指向外部 URL。 JSF 人员已请求此功能。另请参阅 JSF 规范问题 598。目前计划在 2.2 版本发布,但我不认为它会在那时实现,因为它目前的投票数为 0。

在此之前,您需要在 中使用纯 HTML

<h:head>
    ...
    <ui:insert name="resources" />
</h:head>

<ui:define name="resources">
    <link rel="stylesheet" type="text/css" src="http://.../foo.css" />
    <script type="text/javascript" src="http://.../foo.js"></script>
</ui:define>

更新 JSF 实用程序库OmniFaces 自版本 1.2 起就有 CDNResourceHandler 可用,可用于自动在生产阶段运行时,将 JSF 资源替换为 CDN 资源。另请参阅CDNResourceHandler 展示页面

This is not possible with <h:outputScript> and <h:outputStylesheet> yet, as they can only point to webapp's own resources, not to an external URL. This feature has already been requested to the JSF guys. See also JSF spec issue 598. Right now it's scheduled for 2.2, but I don't expect it to be already implemented then as it's currently at 0 votes.

Until then, you'd need to specify them yourself using plain HTML <link> and <script> in <h:head>. You could make it a template definition if necessary, surely when you'd like to define them on a per-view basis.

<h:head>
    ...
    <ui:insert name="resources" />
</h:head>

and

<ui:define name="resources">
    <link rel="stylesheet" type="text/css" src="http://.../foo.css" />
    <script type="text/javascript" src="http://.../foo.js"></script>
</ui:define>

Update the JSF utility library OmniFaces has since version 1.2 a CDNResourceHandler available which could be used to automatically replace JSF resources by CDN resources when running in production stage. See also the CDNResourceHandler showcase page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文