@RequestMapping(value = "/image/get")
    public void getImage(HttpServletRequest request,HttpServletResponse response) {
        FileInputStream fis = null;
        response.setContentType("image/gif");
        try {
            OutputStream out = response.getOutputStream();
            File file = new File("D:"+File.separator+"timg.jpg");
            fis = new FileInputStream(file);
            byte[] b = new byte[fis.available()];
            fis.read(b);
            out.write(b);
            out.flush();
        } catch (Exception e) {
             e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                   fis.close();
                } catch (IOException e) {
                e.printStackTrace();
            }   
              }
        }
    }

相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2020-06-15
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-08-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-19
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
相关资源
相似解决方案