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();
}
}