【发布时间】:2017-01-19 02:27:38
【问题描述】:
我在加载 base 64 格式的图像时遇到了一点问题。
在前端我有:
<img src="/path/to/rest/image">
其余服务表示:
@GET
@PublicResource
@Produces("image/*")
@Path("/path/to/rest/image")
public Response getResource() {
CacheControl cacheControl = new CacheControl();
cacheControl.setMaxAge(86400);
cacheControl.setPrivate(true);
//image.imputStream() is the stream of the image's base64 representation
Response.ok(image.getInputStream())).cacheControl(cacheControl)
.header("Cache-Control", "max-age=86400").build();
}
它返回正确的 base64,当我在任何解析器中将其解析为图像时,它会显示图像。但是 img 标签仍然显示图像已损坏。 任何想法如何解决它?可能我必须添加一些标题。
【问题讨论】:
标签: java html image rest base64