无为清净楼资源网 Design By www.qnjia.com

1、jsp

 <img alt="test" src="/UploadFiles/2021-04-02/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地址是一个请求的方式来显示图片方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
img,src,请求

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com