今天热门
热点:

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);  


可以参考一下这段..

///

引用
谢谢,但是这个不是应该用outputStream的方式,发送到服务器上吗。。。??

发送http请求,有很多接口可以用的。上面是一种,你说的是另一种。

www.zrccd.nettrue/topics/20181012/188463.htmlTechArticlehttpclient post如何发送json到服务器,httpclientjson android 与后台交互,需要用json发送到服务器,json已经拿到,如何发送呢??? 解决方案 JSONObjectjsonParam=newJSONObject(); jsonParam.put("chnl_id","...

相关文章

    暂无相关文章

用户评论

大家都在看