依赖jar包
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
发送请求
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod("https://xxx/xxxx");
postMethod.addRequestHeader("content-type", "application/json;charset=UTF-8");
postMethod.addRequestHeader("accept", "application/json;charset=UTF-8");
//添加请求参数
postMethod.setRequestEntity(new StringRequestEntity(dataObj.toString(), "application/json", "UTF-8"));
httpClient.executeMethod(postMethod);
String result = postMethod.getResponseBodyAsString();
标签:Java,请求,UTF,发送,application,json,HttpPost,postMethod,new
From: https://www.cnblogs.com/zhang-han/p/17044785.html