GlassFish alternatedocroot路径应该如何在h:graphicImage中显示图像?

The*_*eph 5 jsf image glassfish

我在index.xhtml文件中显示图像时遇到问题.

我希望我的数据库中的链接指向图像文件,以便一个<h:graphicImage/><img />标记可以显示它.目前仅使用localhost.

我已设法将图像保存到c:\ var\webapp\images \并添加<property name="alternatedocroot1" value="from=/images/* dir=/var/webapp" />到我的glassfish-web.xml并使用:

<h:graphicImage value="#{entity.imageLink}" />
<img alt="#{entity.title}" src="#{entity.imageLink}" />
Run Code Online (Sandbox Code Playgroud)

但我从来没有设法显示任何图像!应该在我的数据库中写什么来显示保存在c:\ var\webapp\images\imageExample.jpg中的imageExample.jpg?我的想法是问题出在我的道路上,但我可能错了.

The*_*eph 1

解决这个问题如下:

更改
<property name="alternatedocroot1" value="from=/images/* dir=/var/webapp" />

<property name="alternatedocroot_1" value="from=/images/* dir=c:\var\webapp" />
注意斜杠。

在我的数据库(MySQL)中,我保存/images/imageExample.jpg它然后将显示为<h:graphicImage value="#{entity.imageLink}" /> .

我现在可以访问该图像http://localhost:8080/<MyAppName>/images/imageExample.jpg