Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以这就是问题所在。我将图像以 bytea(字节数组)类型存储在 PostgreSQL 中。我还有一个主页 JSP 页面,它必须显示来自 db 的所有照片。请指出解决方案或实现此要求的一些方法。最诚挚的问候。纳扎尔
使用 [img src="url"] 标签从数据库中引用您的图像并在网站上显示。
var blob = new Blob([bytes], {type: "image/jpg"}); var url = URL.createObjectURL(blob, { oneTimeOnly: true });
Blob 实际上由 URL.createObjectURL 直接支持。唯一的问题是您必须指定一个 mime 格式来识别缓冲区格式,这在我的情况下是可能的。
因此,在您获得网址后,请使用图像标签。告诉我它是否有效。