火点转发-乱码

This commit is contained in:
liuchengqian 2022-11-12 15:39:15 +08:00
parent 94a90a8f1e
commit ad57a3e46f
2 changed files with 18 additions and 1 deletions

View File

@ -510,7 +510,7 @@ public class FirePointServiceImpl implements FirePointService {
private void forwardPoint(FirePointEntity firePointEntity) { private void forwardPoint(FirePointEntity firePointEntity) {
try { try {
String url = "http://121.36.229.60:6811/insertfirepointchannelThree"; 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -75,6 +75,23 @@ public class HttpClientUtils {
return doPost(httpClient, url, params); 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请求 * 发送https+post请求
* *