h:graphicimage 在 c:foreach 中不起作用
我使用 c:forEach 循环使用 h:graphicImage 显示图像列表。但我无法显示图像。我的页面中也有 h:commandLink 。图像必须在表单初始化时显示。但它不起作用。但点击h:commandlink后,图像显示正常。在此之前,它显示图像未找到文本(替代消息)。我使用了 h:graphicImage 标签,如下所示
<c:forEach items="#{Sample.imageList}" var="images" varstatus="imageStatus">
<h:graphicimage id="image" url="#{images}" alt="Image Not Found"/>
</c:forEach>
我做错了什么以及如何实现这一点?
I have used c:forEach loop for display the list of images using h:graphicImage. But I can't display the images. I have the h:commandLink also in my page. The image have to be displayed at the time of form inititalization. But its not working. But after click the h:commandlink, the images are displayed properly. Before that it shows the image not found text (alt message). I have used h:graphicImage tag like below
<c:forEach items="#{Sample.imageList}" var="images" varstatus="imageStatus">
<h:graphicimage id="image" url="#{images}" alt="Image Not Found"/>
</c:forEach>
What I do wrong in that and how can I achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
图像 URL 是相对于浏览器地址栏中的 URL 的。显然,命令链接被转发到一个 URL,这使得相对图像 URL 有效。
要解决此问题,您需要知道图像的绝对 URL(以http://开头)和相关页面的绝对 URL。然后,您可以从中提取图像的正确相对 URL 并在
h:graphicImage
中使用它。The image URL is relative to the URL in the browser address bar. Apparently the commandlink was forwarded to an URL which made the relative image URL's valid.
To fix this problem, you need to know the absolute URL (starting with http://) of the images and the absolute URL of the page in question. Then you can extract the right relative URL for the image from this and use this in
h:graphicImage
.