1

我有以下 primefaces 组件,它应该只加载/WEB-INF/Resource/{1.png,2.png,3.png,4.png}.

<p:ring id="weatherForecasts" value="#{eventPageCreatorBean.weatherForecasts}" var="weatherForecast" styleClass="image-ring" easing="easeInOutBack">
    <p:panelGrid columns="1">
        #{weatherForecast.forecastStart}
        <p:graphicImage id="img" name="/WEB-INF/Resources/images/#{weatherForecast.weatherCondition.code}.png" />
        #{weatherForecast.forecastEnd}
    </p:panelGrid>
</p:ring>

通过从浏览器检查源代码,我得到了这个路径:

/meteocal-web/javax.faces.resource//WEB-INF/Resources/images/1.png.xhtml

有谁知道如何解决它?

4

1 回答 1

1

在 JSF2 中,您的所有 Web 资源文件(如 CSS、图像或 .js 文件)都可以放在resourcesWeb 应用程序根目录下的文件夹中(与 .js 相同级别WEB-INF)。

>webapp
   |
   -->resources
   |      |
   |      -->images
   |           |
   |           1.png
   -->WEB-INF

然后您将能够将相应的文件夹称为library

<p:graphicImage id="img" 
                library="images" 
                name="#{weatherForecast.weatherCondition.code}.png}" />
于 2015-01-24T09:08:33.450 回答