//前端發送get請求 後端直接經過url,瀏覽器下載圖片 URL url = new URL(qrcodeImageVo.getExclusiveUrl()); response.setContentType("application/x-msdownload;"); response.setHeader("Content-disposition", "attachment; filename=" + new String(getImageName().getBytes("UTF-8"), "ISO-8859-1")+Constants.JPG); byte[] buff = new byte[2048]; BufferedInputStream is = new BufferedInputStream(url.openStream()); BufferedOutputStream os = new BufferedOutputStream(response.getOutputStream()); int bytesRead; while (-1 != (bytesRead = is.read(buff, 0, buff.length))) { os.write(buff, 0, bytesRead); } if (is != null){ is.close(); } if (os != null){ os.close(); }