---dao
query.addScalar("blob",Hibernate.BLOB);
query.setParameter(0,id);
Blob blob = (Blob) query.uniqueResult();
InputStream is = null;
byte[] b = null;
try {
is = blob.getBinaryStream();
b = new byte [( int ) blob.length ()];
is.read ( b );
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try
{
is.close ();
is = null;
}
catch ( IOException e )
{
e.printStackTrace ();
}
}
return b;
--- rest类
String s = Base64.encodeBase64String(basicInformationService.queryPhotoDoorImg(sAreaId));
return s 到前端;
-----------前端
imgUrl = "data:image/jpg;base64,";
dojo.xhrPost({
url: ""
preventCache: true,
timeout: jgCom.timeout,
content: {
sAreaId:jgCom.areaInfo.areaId
},
load: dojo.hitch(this, function (response, ioArgs) {
var res = response;
imgUrl = imgUrl + res;
}),
error: function(response, ioArgs) {
if (jgCom.useFinger) {
jgCom.fingerRestart();
}
console.error("wfrmlogin getUseridByzw_HD ",response, ioArgs);
return;
}
});
数据库中blob_base64显示(ie11)
最新推荐文章于 2023-04-26 14:55:07 发布