如何从资源文件夹中引用p:graphicImage中的img

时间:2016-11-23 17:39:32

标签: jsf primefaces graphicimage

我在以下路径中有一张图片:

resources
\_____img
 \_______sites
  \_______reddit.png

我使用此命令行来引用它:

<p:graphicImage library="img" name="/sites/reddit.png"/>

但在开发控制台中它说:

GET http://localhost:8080/RES_NOT_FOUND 404 ()

并且不会渲染图像。

出了什么问题?

1 个答案:

答案 0 :(得分:5)

Kukeltje建议的网址(What is the JSF resource library for and how should it be used?)是解决此问题的权威资源。

基于该URL,我认为资源文件夹不应该在WEB-INF下。假设您使用默认的maven项目布局

,它应具有如下结构
src/main/webapp/resources
-------------------------/img
-----------------------------/sites
-----------------------------------/reddit.png
src/main/webapp/WEB-INF
-----------------------/web.xml

然后以下JSF构造应该可以工作。

<p:graphicImage library="img" name="sites/reddit.png"/>
相关问题