【发布时间】:2010-05-03 07:48:26
【问题描述】:
我有一个名为 Common/Images/Photounavailable.jpg 的文件夹。这是从根目录引用图像的正确方法吗?我想从我的 Web 应用程序的任何文件夹中的任何页面引用此图像。
private String getPhotoUnavailablePath = "/Common/Images/PhotoNotAvailable.jpg";
private String getPhotoUnavailablePath(){
return photoUnavailablePath;
}
在我的 JSF 页面中,我写了类似的内容:-
<h:outputLink id ="blogPhoto" value="#{BlogBean.photoUnavailablePath}" >
<h:graphicImage value="#{BlogBean.photoUnavailablePath}" style="width: 180px;height: 180px;"/>
</h:outputLink>
我在 h:graphicImage 中看到了图像。但是当我点击它时,我得到 404 错误。 OutputLink 没有正确链接到图像。这怎么可能?那 h:graphicImage 得到正确的链接而 h:outputLink 没有?
此外,此代码完美运行:-
<h:outputLink id ="blogPhoto" value="..#{BlogBean.photoUnavailablePath}" >
<h:graphicImage value="#{BlogBean.photoUnavailablePath}" style="width: 180px;height: 180px;"/>
</h:outputLink>
只需输入.. 即可!谁能解释一下发生了什么以及如何解决这个问题?
【问题讨论】: