SpringBoot使用httpclient发送Post请求的注意事项和示例代码
public static String post(String url, String params){ log.info("post url:" + url + " params:" + params); String responseStr = ""; try(CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost(url); StringEntity stringEntity = new StringEntity(params, Charset.forName("UTF-8")); httpPost.setHeader("Content-type", "application/json"); httpPost.setEntity(stringEntity); Closeable
用户评论