- A+
所属分类:Java
1、StringEntity
String param = "channelId=4&category=1&sortOrder=1&keywords="; JSONObject param1= new JSONObject(); param1.put("channelId", 4); param1.put("category",1); param1.put("sortOrder",1); param1.put("keywords",""); param = param1.toString();
StringEntity params = new StringEntity(param1, Consts.UTF_8);
第一个的param按理说也可以,不知道为什么突然不行了。
2、UrlEncodedFormEntity
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
NameValuePair pair1 = new BasicNameValuePair("supervisor", supervisorEt.getEditableText().toString());
NameValuePair pair2 = new BasicNameValuePair("content", superviseContentEt.getEditableText().toString());
NameValuePair pair3 = new BasicNameValuePair("userId", String.valueOf(signedUser.getId()));
pairs.add(pair1);
pairs.add(pair2);
pairs.add(pair3);
httpPost.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8))