public class httpClientStuParam06Test { @Test public void getParam() throws URISyntaxException { System.out.println(" Test httpClient configuration "); / / 1: create an httpClient object CloseableHttpClient httpClient. = HttpClients createDefault (); / / 2: Set the request parameter/http://yun.itheima.com/search?keys=Java/create URIBuilder URIBuilder URIBuilder = new URIBuilder("http://yun.itheima.com/search"); Uribuilder.setparameter ("keys", "Java").setParameter("login","userName"); Uribuilder.setparameter ("keys", "Java").setParameter("login", "下 载 "); HttpGet httpGet = new HttpGet(uriBuilder.build()); System.out.println(" HTTP request information :"+httpGet); // Returned value: HTTP request information: GET http://www.itcast.cn HTTP/1.1 //3: set the variables for receiving the request response, such as the main and necessary information (host, API, HTTP code, response code, response time, etc.). CloseableHttpResponse response=null; try { response= httpClient.execute(httpGet); If (response.getStatusLine().getStatusCode()==200){ Pass to the variable content String Content = Entityutils.toString (Response.getentity (), "utf8"); System.out.println(" +content.length()) "); } } catch (IOException e) { e.printStackTrace(); }}}Copy the code

The original link www.cnblogs.com/asplover/p/…