//先进行图片的base64编码,然后把该string类型编码传入页面使用即可
public static String GetImageStr(File image) {
byte[] data = null;
try {
InputStream in = new FileInputStream(image);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
}
//页面上使用如下方法得到图片(XXX...为编码字符串)
<object type="image/bmp" data="data:image/bmp;base64,XXX..." style="width: 140px; height: 40px;"></object>
或者:
<img src="https://img-blog.csdnimg.cn/2022010703070245725.png">