【发布时间】:2016-12-18 16:03:24
【问题描述】:
我尝试了很多方法来在我的 jsf 页面中包含背景图片,但都没有奏效。虽然我的页面可以识别我的样式表(因为它显示红色文本),但不包括图像。我应该在 pom.xml 中添加映射资源吗? 请指教。
This is my folder structure:
`WebContent
|-- META-INF
|-- WEB-INF
|-- resources
| |-- css
| | |-- style.css
| |-- images
| |-- background.png
|-- index.xhtml
这是我在 index.xhtml 中添加的:
<h:body class="main">
<h:outputStylesheet library="css" name="index.css"></h:outputStylesheet>
<p class="test"> some text </p>
</h:body>
这是我的 style.css:
.main {
background-image: url("#{resource['images:background.png']}");
}
.test {
color : red;
}
【问题讨论】:
-
您能否访问您的资源输入
yourbaseurl/javax.faces.resource/images/background.png? -
离题(虽然不完全):stackoverflow.com/questions/11988415/…
标签: css image jsf background