public class HttpClientDemo {
public void doGet() throws URISyntaxException, IOException {
String url = "http://192.....";
//创建client
CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象
URIBuilder uriBuilder = new URIBuilder(url);
uriBuilder.addParameter("account","123");
uriBuilder.addParameter("password","123");
//get方法
HttpGet httpGet = new HttpGet(uriBuilder.build());
//执行请求
CloseableHttpResponse response = client.execute(httpGet);
//获取打印结果
//查看状态码
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(statusCode);
//打印内容
//获取响应实体
HttpEntity entity = response.getEntity();
String str = EntityUtils.toString(entity, "utf-8");
System.out.println(str);
response.close();
client.close();
}