在Netbeans中,我有一个名为css的子文件夹,其中有一个名为testcss.css的文件.
In Netbeans I have a sub folder called css and a file in it called testcss.css.
如何从根目录获取Facelets文件以访问testcss.css文件?
How do I get Facelets file from root to access the testcss.css file?
<meta http-equiv="content-type" content="text/html; charset=windows-1252" /> <link rel="stylesheet" type="text/css" href="/testcss.css" title="style" />我的目录结构是:
Root (not a folder) css (folder) testcss.css此处.. /p>
A screenshot of the structure is available here.
推荐答案您应将CSS(以及JS和图像)资源放在/resources文件夹中(如果不存在,则创建一个).
You should put CSS (and JS and image) resources in /resources folder (create one if it doesn't exist).
Web Pages |-- META-INF |-- WEB-INF |-- resources | |-- css | | `-- style.css | |-- js | | `-- script.js | `-- img | `-- logo.png |-- index.xhtml :完成此操作后,您应该能够使用适当的JSF组件引用CSS(以及JS和图像)资源 <h:outputStylesheet> (和 <h:outputScript> 和 <h:graphicImage> )如下:
Once accomplished that, you should be able to reference the CSS (and JS and image) resources using the appropriate JSF components <h:outputStylesheet> (and <h:outputScript> and <h:graphicImage>) as follows:
<h:outputStylesheet name="css/style.css" /> <h:outputScript name="js/script.js" /> <h:graphicImage name="img/logo.png" />无需摆弄相对路径. JSF将自动生成正确的URL.
No need to fiddle with relative paths. JSF will automagically generate the proper URL.
- 如何在Facelets模板中引用CSS/JS/图像资源? /a>
- > JSF资源库以及如何使用它?
- 具有共享代码的多个JSF项目的结构
- How to reference CSS / JS / image resource in Facelets template?
- What is the JSF resource library for and how should it be used?
- Structure for multiple JSF projects with shared code
更多推荐
从子文件夹获取.css文件
发布评论