开发者

image not showing on h:gaphicImage when myReturn button is click but it shows when navigator's back is clicked

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>


<h:graphicImage value="../includes/images/#{item.cover}" />

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.

<h:graphicImage value="/includes/images/#{item.cover}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜