0

如何通过使用“=”代替“:”将键值对中的数据传递到HttpPostAndroid中?

像这样:

"firstName" = "abc"
"lastName" = "xyz"
4

1 回答 1

1

我不知道您使用“=”代替“:”是什么意思,但我猜您正在尝试使用参数发布。你可以尝试这样的事情:

HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
nameValuePairs.add(new BasicNameValuePair("firstName", "abc"));
nameValuePairs.add(new BasicNameValuePair("lastName", "xyz"));
try {
    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    httpClient.execute(httpPost);
}
于 2013-03-28T15:49:00.720 回答