Merge remote-tracking branch 'origin/master'

This commit is contained in:
15856 2024-09-04 09:39:47 +08:00
commit 9461d70325
1 changed files with 3 additions and 3 deletions

View File

@ -41,16 +41,16 @@ public class HttpHelper {
System.out.println("JSONBody-=========:" + JSONBody); System.out.println("JSONBody-=========:" + JSONBody);
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json"); httpPost.addHeader("Content-Type", "application/json; charset=UTF-8");
if (!CollectionUtils.isEmpty(headerMap)) { if (!CollectionUtils.isEmpty(headerMap)) {
for (Map.Entry<String, String> entry : headerMap.entrySet()) { for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.addHeader(entry.getKey(), entry.getValue()); httpPost.addHeader(entry.getKey(), entry.getValue());
} }
} }
httpPost.setEntity(new StringEntity(JSONBody)); httpPost.setEntity(new StringEntity(JSONBody,StandardCharsets.UTF_8));
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, "UTF-8"); String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8);
response.close(); response.close();
httpClient.close(); httpClient.close();
return responseContent; return responseContent;