从子文件夹获取.css文件

编程入门 行业动态 更新时间:2024-10-20 16:03:00
本文介绍了从子文件夹获取.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和图像)资源 <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文件

本文发布于:2023-11-09 21:05:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573431.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件   从子   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!