从子文件夹获取.css文件 [英] get .css file from a sub folder

查看:83
本文介绍了从子文件夹获取.css文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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和图像)资源

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.

  • 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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆