|
@ -12,6 +12,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.impl.client.HttpClients;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@ -25,6 +27,8 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
public class HttpClientUtil {
|
|
public class HttpClientUtil {
|
|
|
|
|
|
|
|
private Logger logger= LoggerFactory.getLogger(HttpClientUtil.class);
|
|
/**
|
|
/**
|
|
* 发送post请求
|
|
* 发送post请求
|
|
*
|
|
*
|
|
@ -92,12 +96,8 @@ public class HttpClientUtil {
|
|
} finally {
|
|
} finally {
|
|
response.close();
|
|
response.close();
|
|
}
|
|
}
|
|
} catch (ClientProtocolException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (ParseException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("http error:"+e.getMessage()+", url:"+url);
|
|
} finally {
|
|
} finally {
|
|
// 关闭连接,释放资源
|
|
// 关闭连接,释放资源
|
|
try {
|
|
try {
|