java 链接到 JSF 中的 CSS 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5861326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linking to a CSS file in JSF?
提问by rich
Within <h:head/>
tags I have:
在<h:head/>
标签内我有:
<h:outputStylesheet name="css/common.css" />
<h:outputStylesheet name="css/common.css" />
This is output as:
这是输出:
<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND" />
<link type="text/css" rel="stylesheet" href="RES_NOT_FOUND" />
The stylesheet is within a folder named css under the webapp folder of my maven war. When I browse to http://localhost:8080/mywar/css/common.cssI see the stylesheet.
样式表位于我的 maven war 的 webapp 文件夹下一个名为 css 的文件夹中。当我浏览到http://localhost:8080/mywar/css/common.css 时,我看到了样式表。
Any ideas what I'm missing? Thanks in advance.
任何想法我错过了什么?提前致谢。
回答by rich
I followed the directory structure and layout from tip 4 here: http://www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html
我遵循了技巧 4 中的目录结构和布局:http: //www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html
Essentially moved the css folder to be under one called resources and then referenced it as:
基本上将 css 文件夹移动到一个叫做资源的下面,然后将其引用为:
<h:outputStylesheet library="css" name="common.css" />
<h:outputStylesheet library="css" name="common.css" />
Now it seems to work!
现在它似乎起作用了!