前言:使用httpclient请求一个http请求的步骤是:
1. 创建一个HttpClient对象
2. 创建一个Request对象
3. 使用httpclient来执行Request请求,得到对方的response
4. 处理response
简单的封装下httpclient。新建一个HttpUtil工具类,将get方法和post方法进行了一个简单的封装。
1. 准备:

2. get请求。带输入参数。 url为 请求地址,param为参数
1. url拼接,,参数为map

2 开始请求:

2. post请求。带输入参数。 url为 请求地址,param为参数,参数为map

网友评论