常用的http的get请求方法
package com.datahthx.credit.test;
import com.datahthx.credit.util.Constant;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
public class java {
@Test
public static void main(String[] args) throws Exception {
try {
String code = Constant.NULL_STR;
String url = "http://10.13.13.230:9001/api/ECIComplement/GetInfo" + "?searchKey=" + "奇台县源淼商贸有限公司";
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("tfapi-key", "sysadmin-key");
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
CloseableHttpResponse execute = closeableHttpClient.execute(httpGet);
String resultStr = EntityUtils.toString(execute.getEntity(), "UTF-8");
System.out.println(resultStr);
} catch (Exception e) {
e.printStackTrace();
}
}
}
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号