HttpClient

 

 

 

 

----------------用list传参数--------------

String urls="";

HttpPost httpPost = new HttpPost(urls);

httpPost.setHeader("Content-type","application/x-msdownload;charset=utf-8");

List<NameValuePair> list = new ArrayList<>();

list.add(new BasicNameValuePair("username","123"));

list.add(new BasicNameValuePair("password","456"));

UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, Consts.UTF_8);

httpPost.setEntity(urlEncodedFormEntity);

-------------------------------------------------传json,与外部系统对接时这种方式比较多。-----------------------------------------

 

posted @ 2021-09-09 17:17  天才淇露洛  阅读(32)  评论(0)    收藏  举报