0
ベース64形式で画像を読み込む際に少し問題があります。私はフロントエンドでbase64の画像をrestサービスからimg srcタグに戻す
: <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タグはまだ画像が壊れていることを示しています。 これを修正する方法はありますか?おそらく私はいくつかのヘッダーを追加する必要があります。
から返されました。 – user3568791
画像はJPEG以外の種類の画像である可能性があります。 –
データを確認してください:image/png; base64、iVBORw0KGgoAAAAN ...これはpngです。 – user3568791