单击 myReturn 按钮时,图像未显示在 h:gaphicImage 上,但单击导航器的后退时,图像会显示
代码如下所示:
<h:dataTable value="#{movie.movieItems}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="Cover"/>
</f:facet>
<h:graphicImage value="../includes/images/#{item.cover}" styleClass="covers"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Nanme"/>
</f:facet>
<h:outputText value="#{item.name}" styleClass="info"/>
</h:column>
This is what the code looks like:
<h:dataTable value="#{movie.movieItems}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="Cover"/>
</f:facet>
<h:graphicImage value="../includes/images/#{item.cover}" styleClass="covers"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Nanme"/>
</f:facet>
<h:outputText value="#{item.name}" styleClass="info"/>
</h:column>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于图像 URL 不以方案或
/
开头,因此它与当前请求 URL(显示在浏览器地址栏中的 URL)相关。在它不起作用的页面中,页面本身显然是由 URL 中的额外路径调用的。这将使图像无法访问。您需要使用完整的 URL 使其绝对化,或以
/
开头使其相对于域。我建议采用后一种方法。假设 Web 应用程序在 http://example.com/appname 上运行,并且图像可通过 http://example.com/appname/includes/images/name.ext,然后以下应该做。
已经考虑了上下文路径。Since the image URL does not start with a scheme or
/
, it becomes relative to the current request URL (the one which appears in browser address bar). In the page where it's not working, the page itself is apparently called by an extra path in the URL. It will make the image unreachable.You need to make it absolute by using the full URL or relative to the domain by starting with
/
. I'd suggest the latter approach. Assuming that the webapp runs on http://example.com/appname and that the image is available by http://example.com/appname/includes/images/name.ext, then the following should do. The<h:graphicImage>
already takes the context path into account.