如何通过使用“=”代替“:”将键值对中的数据传递到HttpPost
Android中?
像这样:
"firstName" = "abc"
"lastName" = "xyz"
我不知道您使用“=”代替“:”是什么意思,但我猜您正在尝试使用参数发布。你可以尝试这样的事情:
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);
}