jsf - 如何在 p :graphicImage from the resource folder 中引用图像

标签 jsf primefaces graphicimage

这个问题在这里已经有了答案:





How to reference CSS / JS / image resource in Facelets template?

(4 个回答)


4年前关闭。




我在以下路径中有一个图像:

resources
\_____img
 \_______sites
  \_______reddit.png

我用这个命令行来引用它:
<p:graphicImage library="img" name="/sites/reddit.png"/>

但在开发控制台中它说:
GET http://localhost:8080/RES_NOT_FOUND 404 ()

并且图像没有被渲染。

怎么了?

最佳答案

Kukeltje 建议的 url ( 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"/>

关于jsf - 如何在 p :graphicImage from the resource folder 中引用图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40771002/

相关文章:

jsf - p :graphicImage which can show images from byte[] and control browser cache 的替代方案

jsf h :messages/h:message for specific clientId

javascript - 禁用命令按钮,直到勾选复选框

primefaces - p :inputText size attribute doesn't limit allowed text length

jsf - 使用 includeViewParams=true 的ExternalContext#redirect()

ajax - 如何在单击 p :graphicImage? 时触发 ajax 事件监听器

jsf - 如何使用<p :graphicImage> with DefaultStreamedContent in an ui:repeat?

JSF commandButton URL 参数

java - 如何在从 <ui :repeat> 生成的 <tr> 中添加命令链接

java - 在 JSF 页面设置要访问 "local"的 "globally"变量