小编Jan*_*ten的帖子

从JSF 2.0中的CSS资源中加载图像

我是JavaServer Faces的新手,我正在尝试执行以下操作:

模板文件"/template.xhtml"使用加载样式表

<h:outputStylesheet library="style" name="default.css" />
Run Code Online (Sandbox Code Playgroud)

在那个CSS文件中我想链接到这样的图像:

... background-image: url(LINK_TO_MY_IMAGE) ...
Run Code Online (Sandbox Code Playgroud)

如何引用该图像(我应该写入LINK_TO_MY_IMAGE)?我已经尝试使用直接链接(/contextroot/resources/images/foo.png)和JSF资源表示法(/contextroot/faces/javax.faces.resource/foo.png?ln=images).

我的目录结构:

/resources/images  => contains image files
/resources/style/default.css
/WEB-INF/web.xml
/WEB-INF/faces-config.xml
/template.xhtml
/demoPage.xhtml  => uses the template.xhtml
Run Code Online (Sandbox Code Playgroud)

所以,到目前为止,我的问题是我总是得到一个"404 Not Found"来加载图像.

css resources jsf jsf-2

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

css ×1

jsf ×1

jsf-2 ×1

resources ×1