在我的应用程序中,我试图发送带有 UserId 等参数的 JSONObject,任何人都可以向我推荐一些教程,我可以从中获得一些帮助......
我得到了这段代码,但在这段代码中,我只能发送 JSONObject 而不是参数..
我的网址是这样的:http ://www.example.com/JSONObject/userId
我如何将带有 userId 的 JSONObject 传递给服务器..
public class HTTPPoster {
public HttpResponse doPost(String url, JSONObject jsonProfilo) throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
HttpEntity entity;
StringEntity s = new StringEntity(jsonProfilo.toString());
s.setContentEncoding((Header) new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
entity = s;
request.setEntity(entity);
HttpResponse response;
response = httpclient.execute(request);
return response;
}
}
谢谢..