我应该使用URL作为图像和其他资源的链接,还是应该使用EL#{resource ...} [英] Should I use URLs as links to images and other resources or should I use the EL #{resource...}
问题描述
我将图片,css和javascript(文件夹名称相同)文件保存在webapp根目录的资源文件夹中。我应该使用URL来显示图像,例如graphicImage标签,还是应该使用#{resources:libraryName ..}
?
I save images, css, and javascript (the folders has the same name) files in a resource folder in the webapp root. Should I be using URLs to get show the image in for example a graphicImage tag or should I be using the #{resources:libraryName..}
?
推荐答案
只需使用提供的 < h:outputStylesheet>
, < h:outputScript>
和 < h:graphicImage>
组件,其中您在 name
属性中指定相对于resources文件夹的路径:
Just use the therefor provided <h:outputStylesheet>
, <h:outputScript>
and <h:graphicImage>
components wherein you specify a path relative to the resources folder in the name
attribute:
<h:outputStylesheet name="css/style.css" />
<h:outputScript name="js/script.js" />
<h:graphicImage name="images/logo.png" />
JSF会担心设置正确的URL。
JSF will worry about setting the right URL.
The #{resource}
syntax is only necessary inside CSS files to reference background images.
- How to reference CSS / JS / image resource in Facelets template?
- How to reference JSF image resource as CSS background image url
这篇关于我应该使用URL作为图像和其他资源的链接,还是应该使用EL#{resource ...}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!