|
@ -36,6 +36,7 @@ public class HttpUtil { |
|
|
public static String doPost(String url, String jsonStr, HashMap<String,String> headers) { |
|
|
public static String doPost(String url, String jsonStr, HashMap<String,String> headers) { |
|
|
CloseableHttpClient client = HttpClientBuilder.create().build(); |
|
|
CloseableHttpClient client = HttpClientBuilder.create().build(); |
|
|
CloseableHttpResponse response = null; |
|
|
CloseableHttpResponse response = null; |
|
|
|
|
|
String errorMsg = null; |
|
|
try { |
|
|
try { |
|
|
//设post请求
|
|
|
//设post请求
|
|
|
HttpPost post = new HttpPost(url); |
|
|
HttpPost post = new HttpPost(url); |
|
@ -57,6 +58,7 @@ public class HttpUtil { |
|
|
return EntityUtils.toString(response.getEntity()); |
|
|
return EntityUtils.toString(response.getEntity()); |
|
|
} |
|
|
} |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
|
|
|
errorMsg = e.getMessage(); |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
}finally { |
|
|
}finally { |
|
|
try { |
|
|
try { |
|
@ -68,7 +70,7 @@ public class HttpUtil { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return null; |
|
|
return errorMsg; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static String doGet(String url, HashMap<String,String> headers) { |
|
|
public static String doGet(String url, HashMap<String,String> headers) { |
|
|