<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>org.apache.commons.httpclient</artifactId>
<version>3.1.LIFERAY-PATCHED-1</version>
<scope>compile</scope>
</dependency>
@Test
void test01() {
String url = "http://***************************";
Msg msg2 = new Msg();
String msg= JSON.toJSONString(msg2);
HttpPost httpPost = new HttpPost(url);
CloseableHttpClient httpClient = HttpClients.createDefault();
StringEntity entity = new StringEntity(msg, "utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("text/json");
httpPost.setEntity(entity);
try {
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity entity1 = httpresponse.getEntity();
String content= EntityUtils.toString(entity1,"utf8");
System.out.println(content);
} catch (ClientProtocolException e) {
} catch (IOException e) {
e.printStackTrace();
}
}