[英]JSF 2.0 How to link CSS from resources folder
I'm designing the template for my new JSF2.0 App and I want to use the resources folder to store my css-file. 我正在为我的新JSF2.0应用程序设计模板,我想使用resources文件夹来存储我的css文件。 Now I started to create a template-file, but I don't know how to link the css.
现在我开始创建模板文件,但我不知道如何链接css。
I tried: 我试过了:
<link rel="stylesheet" type="text/css" href="resources/css/style.css"/>
..but didn't work ..但没有工作
Can somebody help me, pls. 有人可以帮助我,请。 THX
谢谢
<h:outputStylesheet library="css" name="style.css" target="head" />
That doesn't work either :-( 这也不起作用:-(
It still doesn't work! 它仍然无法正常工作! Maybe that resource-method is disabled?!
也许那资源方法被禁用了?! It doesn't work with pictures either!
它也不适用于图片!
<h:graphicImage value="#{resource['img:logo.png']}"/>
The output in my browser looks like that: 我的浏览器中的输出看起来像这样:
<img src="RES_NOT_FOUND">
EDIT: Images working now. 编辑:图像现在工作。 I stupidly set a wrong path -.- but the stylesheet is still not working
我愚蠢地设置了错误的路径-.-但样式表仍然无法正常工作
确保你有h:head / h:body标签。
You need to put public resources in the public webcontent ( /webapp
folder as on your screenshot). 您需要将公共资源放在公共webcontent(
/webapp
文件夹中,如截图中)。 CSS files are downloaded/included by webbrowser, not by webserver and hence need to be directly public accessible. CSS文件由webbrowser下载/包含,而不是由webserver下载,因此需要直接公开访问。
Create a sub-directory resources at the web application root and try. 在Web应用程序根目录下创建子目录资源并尝试。 It will work.
它会工作。
Please refer to http://docs.oracle.com/javaee/6/tutorial/doc/girgm.html 请参阅http://docs.oracle.com/javaee/6/tutorial/doc/girgm.html
I had the same problem everything work after switching those two lignes : 在切换这两个lignes后,我遇到了同样的问题:
from : 来自:
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
to : 至 :
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
It works with plain old html: 它适用于普通的旧HTML:
<link href="./resources/css/style.css" rel="stylesheet" type="text/css" />
But i don't like it I would prefer JSF... 但我不喜欢它我更喜欢JSF ......
<h:outputStylesheet library="css" name="style.css" />
Please check the link below: Reference to CSS under resources folder in jsf. 请检查以下链接:参考jsf中资源文件夹下的CSS。
https://examples.javacodegeeks.com/enterprise-java/jsf/outputstylesheet-example-with-jsf-2-0/ https://examples.javacodegeeks.com/enterprise-java/jsf/outputstylesheet-example-with-jsf-2-0/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.