public static void getImage(HttpServletRequest request, HttpServletResponse response){
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("請求地址");
CloseableHttpResponse resp = null;
try {
resp = httpClient.execute(httpPost);// 調用服務器接口
byte[] data = EntityUtils.toByteArray(resp.getEntity());// 將圖片或者文件轉化成數組的形式
OutputStream toClient = response.getOutputStream();// 獲取輸出流
toClient.write(data);// 將這個數組寫入輸出流中
toClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}