diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 14c4714..bb9fc6c 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -510,7 +510,7 @@ public class FirePointServiceImpl implements FirePointService { private void forwardPoint(FirePointEntity firePointEntity) { try { String url = "http://121.36.229.60:6811/insertfirepointchannelThree"; - HttpClientUtils.sendHttpPost(url, new ObjectMapper().writeValueAsString(firePointEntity)); + HttpClientUtils.sendHttpPostTextPlain(url, new ObjectMapper().writeValueAsString(firePointEntity)); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/com/xkrs/utils/HttpClientUtils.java b/src/main/java/com/xkrs/utils/HttpClientUtils.java index 2d5ac2b..bc45351 100644 --- a/src/main/java/com/xkrs/utils/HttpClientUtils.java +++ b/src/main/java/com/xkrs/utils/HttpClientUtils.java @@ -75,6 +75,23 @@ public class HttpClientUtils { return doPost(httpClient, url, params); } + public static String sendHttpPostTextPlain(String url, String params) throws Exception { + CloseableHttpClient httpClient = HttpClients.createDefault(); + return doPostTextPlain(httpClient, url, params); + } + + private static String doPostTextPlain(CloseableHttpClient httpClient, String url, String params) throws Exception { + log.info("Post请求url:{}", url); + log.info("Post请求params:{}", params); + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader("Content-Type", "application/json; charset=utf-8"); + StringEntity requestEntity = new StringEntity(params, "UTF-8"); + requestEntity.setContentType("text/plain"); + requestEntity.setContentEncoding("UTF-8"); + httpPost.setEntity(requestEntity); + return execute(httpClient, httpPost); + } + /** * 发送https+post请求 *