如何通过在Android中的HttpPost
中使用“=”代替“:”来传递键值对中的数据?
像这样:
"firstName" = "abc"
"lastName" = "xyz"
答案 0 :(得分: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);
}