简体   繁体   English

资源库在h:graphicImage中被忽略

[英]Resource library getting ignored in h:graphicImage

I have the following tag: 我有以下标记:

<h:graphicImage value="Circle_Yellow.png" library="images" />

In my folder I have the following structure: 在我的文件夹中,我有以下结构:

/resources/images/.....
/WEB-INF/....
/*.xhtml

When rendered that image shows up as: 渲染时,该图像显示为:

<img src="Circle_Yellow.png">

However I do see other things using resources, for example 但是,我确实看到了其他使用资源的东西

<script type="text/javascript" src="/www/javax.faces.resource/jquery/jquery.js.xhtmlln=primefaces"></script>

And if I go to /www/javax.faces.resource/Circle_Yellow.png?ln=images it works. 如果我去/www/javax.faces.resource/Circle_Yellow.png?ln=images它可以工作。

So what could I possibly be doing wrong that my library gets ignored on the h:graphicImage. 那么,在h:graphicImage中我的库被忽略,我可能做错了什么呢? Also it isn't just as an image, I have a css file that is failing too. 此外,它不仅仅是一个图像,我有一个失败的CSS文件。

I'm using mojarra 2.1.16 and primefaces 3.4.1. 我正在使用mojarra 2.1.16和primefaces 3.4.1。

The value attribute takes an URL, not the resource name. value属性采用URL,而不是资源名称。 To specify the resource name, use the name attribute. 要指定资源名称,请使用name属性。

<h:graphicImage library="images" name="Circle_Yellow.png" />

See also the <h:graphicImage> tag documentation for details. 有关详细信息,另请参阅<h:graphicImage>标记文档


Unrelated to the concrete problem, your usage of the library attribute is not entirely right. 具体问题无关 ,您对library属性的使用并不完全正确。 Please carefully read What is the JSF resource library for and how should it be used? 请仔细阅读什么是JSF资源库以及如何使用它? You should be using it as 你应该用它作为

<h:graphicImage name="images/Circle_Yellow.png" />

Try using this, 试试这个,

<h:graphicImage value="resources/images/Circle_Yellow.png"/>

or 要么

<h:graphicImage library="images" name="Circle_Yellow.png" />

and include your css like below 并包括你的CSS如下

<h:outputStylesheet library="css" name="style.css" />

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

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