如何在HttpPost中使用参数

如何在HttpPost中使用参数,第1张

如何在HttpPost中使用参数

要为您设置参数,

HttpPostRequest
可以使用
BasicNamevaluePair
,例如:

    HttpClient httpclient;    HttpPost httpPost;    ArrayList<NamevaluePair> postParameters;    httpclient = new DefaultHttpClient();    httpPost = new HttpPost("your login link");    postParameters = new ArrayList<NamevaluePair>();    postParameters.add(new BasicNamevaluePair("param1", "param1_value"));    postParameters.add(new BasicNamevaluePair("param2", "param2_value"));    httpPost.setEntity(new UrlEnpredFormEntity(postParameters, "UTF-8"));    HttpResponse response = httpclient.execute(httpPost);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5615171.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存