使用 JSF2 资源有哪些好处?

发布于 2024-12-07 10:30:01 字数 273 浏览 1 评论 0 原文

我应该使用 JSF2 资源而不是像 url(image.png) 这样的纯 html 吗?有什么好处?对我来说,当网页设计师使用 XHTML、CSS 和所有这些东西创建布局时,这有点烦人,我需要花时间将纯 HTML 路径和标签替换为 JSF 资源标签,例如 #{resource[...] }

还有其他办法吗?喜欢将所有 CSS/图像文件放在 Web 根目录中并使用普通链接吗?

Should I use JSF2 resources instead of plain html like <link href... or url(image.png)? What are the benefits? For me this is a bit annoying when web-designer creates layout with XHTML, CSS and all that stuff and I need to spend time to replace plain HTML paths and tags to JSF resource tags like#{resource[...]}.

Is there any other way? Like to put all CSS/image files in web root and use normal links?

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

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

发布评论

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

评论(1

記柔刀 2024-12-14 10:30:01

你的选择。

主要好处是您可以在每个组件的基础上声明它们。如果您无论如何都需要将它们包含在每个页面上,那么好处就很小了。但是,如果您需要在例如在单个视图中多次重用的复合组件中包含特定于组件的 CSS/JS 代码,那么例如 复合组件中的内容最终会出现在它被包括在内仅一次,而不是像使用

请注意,您并不需要仅使用 JSF2 资源。只是普通的

Your choice.

The major benefit is that you can declare them on a per-component basis. If you need to include them on every single page anyway, then the benefit is little. But if you need to include component-specific CSS/JS code in for example a composite component which is reused more than once in a single view, then for example an <h:outputScript> in a composite component would end up in it being included only once instead of that many times as the composite component is been used as would happen with <script>. The same applies to the @ResourceDependency annotation on real UIComponent classes.

Please note that you are not required to use JSF2 resources only. Just plain vanilla <img>, <link>, <script>, etc is also perfectly fine. It can even point to the JSF resources folder.

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