发送http post请求(Json数据/form表单数据)
加依赖
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.12</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
</dependency>
方法
// json数据请求
public static String sendPost(String requestUrl,String json){
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(requestUrl);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(10000)
.setConnectionRequestTimeout