public static String post(String url, Map<String, String> reqParam) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
// 创建httppost.
HttpPost httppost = new HttpPost(url);
//setConnectTimeout:设置连接超时时间,单位毫秒。
// setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒。
// setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
RequestConfig defaultRequestConfig = RequestConfig.custom().setConnectTimeout(5000
java发送post请求
最新推荐文章于 2024-07-29 14:22:26 发布