JSF,来自数据库的图像和 og:image 集成

JSF, Images from database and og:image integration

我正在使用 JSF 2.2.12、Omnifaces 2.5.1 和 PrimeFaces 6。

在我们的应用程序中,我们决定将图像存储在数据库中,但我们不知道我们可以通过哪种方式使用这种方法。

如果我使用像下面这样的静态图片,一切都很好,

<meta property="og:image" content="http://somePath/myImage.jpg" />

但是对于来自数据库的图像,我们无法做到这一点。

你能帮我们吗?

谢谢!

你应该实现 servlet,它读取你的文件并执行 response.getOutputStream().write(content); 在网页中

<meta property="og:image" content="servletName?passImageId" />

示例应用程序在这里

https://github.com/armdev/jsf-web-app/blob/master/web-platform/src/main/java/com/project/web/handlers/PreviewImage.java