• 周四. 6月 30th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Httpclient———框架

admin

11月 28, 2021

http://hc.apache.org/

—————————————————————————————–

package com.course.httpclient;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.testng.annotations.Test;
import java.io.IOException;
public class MyHttpClient {
@Test
public void test1() throws IOException {
//用来存放我们的结果
System.out.println("");
String result;
HttpGet get=new HttpGet("http://127.0.0.1:8080/pinter/index");
//用来执行get方法的
HttpClient client=new DefaultHttpClient();
HttpResponse response=client.execute(get);
result=EntityUtils.toString(response.getEntity(),"utf-8") ;
System.out.println(result);
}
}

发表评论

您的电子邮箱地址不会被公开。