1、jsp
<img alt="test" src="getimg2.do">
2、controller
@requestmapping("getimg2")
public void getimg2(httpservletrequest request, httpservletresponse response)
throws ioexception {
fileinputstream fis = null;
outputstream os = null;
try {
fis = new fileinputstream("d:/log.png");
os = response.getoutputstream();
int count = 0;
byte[] buffer = new byte[1024 * 8];
while ((count = fis.read(buffer)) != -1) {
os.write(buffer, 0, count);
os.flush();
}
} catch (exception e) {
e.printstacktrace();
} finally {
try {
fis.close();
os.close();
} catch (ioexception e) {
e.printstacktrace();
}
}
}
以上这篇img的src地址是一个请求的方式来显示图片方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持硕编程。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!