PrimeFaces视图中的正确路径

时间:2015-08-06 13:33:42

标签: image jsf primefaces path relative-path

我使用PrimeFaces 5.2版和Glassfish作为服务器来部署我的结果。 我编写了一个简短的例子,以便从服务器下载文件,我遇到了显示与进度条相关的GIF图像的问题。

问题本身就是我无法找到图像的正确路径。我的文件夹结构如下图所示:

Image_1: Project Structure

我将在下面的图片中为您提供更多详细信息:

此图像显示与路径相关的xhtml片段,在本例中为:

  

“图像/ ajaxloadingbar.gif”

您可以看到GIF未正确显示,其他附加代码是由Chrome网络浏览器的Inspect element选项生成并显示的html。

Image_2: Wrong path first try

我注意到我实现了移除javax.faces.resource和最后xhtml扩展的目标(请参阅第3张图片)。

Image_3: Desired Results

知道这种行为我在图像路径中尝试了一些变体,我仍然在努力解决这个问题。以下是我试过的一些没有运气的路径。

Image_4: Path not recognized

  

Unable to find or serve resource, images/ajaxloadingbar.gif.

     

Unable to find or serve resource, /images/ajaxloadingbar.gif.

     

Unable to find or serve resource, ../../images/ajaxloadingbar.gif.

     

Unable to find or serve resource, ../images/ajaxloadingbar.gif.

     

Unable to find or serve resource, Pack_Encrypt/images/ajaxloadingbar.gif.

     

Unable to find or serve resource, /Pack_Encrypt/images/ajaxloadingbar.gif.

     

Unable to find or serve resource, /WebContent/images/ajaxloadingbar.gif.

我非常感谢有关这条棘手路径的任何帮助或想法。我想使用相对路径而不是绝对路径。

亲切的问候, 路易斯A.

1 个答案:

答案 0 :(得分:3)

移动文件夹"图像"进入新文件夹"资源"。

完整路径应为" ... \ WebContent \ resources \ images"

请查看以下页面:

What is the JSF resource library for and how should it be used?