简体   繁体   English

如何为Primefaces GraphicImage设置图像目录

[英]How to set image directory for Primefaces GraphicImage

I have a graphicImage component but I couldn't see my loading.gif file. 我有一个graphicImage组件,但我看不到我的loading.gif文件。 I think there is a problem with file path. 我认为文件路径有问题。 My image is under "Web Pages/Resources/images/loading.gif". 我的图片位于“Web Pages / Resources / images / loading.gif”下。

I am using Netbeans and Here is my page "Web Pages/Pages/customPages/index.xhtml"; 我正在使用Netbeans,这是我的页面“Web Pages / Pages / customPages / index.xhtml”;

<p:blockUI block="myDataTable" trigger="myDataTable">  
            Loading<br />  
            <p:graphicImage library="images" value="loading.gif"/>  
        </p:blockUI

EDIT: These are also didn't work :) 编辑:这些也没有用:)

library="images" value="loading.gif"
library="resources/images" value="loading.gif"
value="loading.gif"
library="resources" value="loading.gif"

EDIT2: Here is how I solved this issue but I don't think it is a good solution. EDIT2:这是我解决这个问题的方法,但我认为这不是一个好的解决方案。 Is there any other way? 还有其他方法吗?

value="#{FacesContext.getCurrentInstance().getExternalContext()}/resources/images/loading.gif"

When you use library attributte you shouldn't use value attributte. 当您使用library attributte时,您不应使用value attributte。 Use name attributte instead. 请改用name attributte。 Try: 尝试:

<p:graphicImage library="images" name="loading.gif" />

use the attributte library to indicate the folder that is inside the resources folder 使用attributte库来指示资源文件夹中的文件夹

<p:graphicImage library="images" name="loading.gif" />

if you use subfolders 如果你使用子文件夹

<p:graphicImage library="images" name="folder1/folder2/loading.gif" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM