httpclient post如何发送json到服务器,httpclientjson
android 与后台交互,需要用json发送到服务器,json已经拿到,如何发送呢???解决方案
JSONObject jsonParam = new JSONObject();
jsonParam.put("chnl_id", "11");
jsonParam.put("title", bean.getTitle());
StringEntity entity = new StringEntity(jsonParam.toString(),"utf-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
HttpPost method = new HttpPost(url);
method.setEntity(entity);
HttpResponse result = httpClient.execute(method);
可以参考一下这段..
///
发送http请求,有很多接口可以用的。上面是一种,你说的是另一种。
用户评论