满意答案
calt08yv4
2014.07.09
采纳率:56% 等级:8
已帮助:712人
[mw_shl_code=java,true]HttpPost httpRequest = new HttpPost(uriAPI); //Post运作传送变数必须用NameValuePair[]阵列储存 List values = new ArrayList(); //在values中添加你的转换成Json后的数据 try{ //发出HTTP request httpRequest.setEntity(new UrlEncodedFormEntity(values, "UTF-8")); //取得HTTP response HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest); //若状态为200,则OK if (httpResponse.getStatusLine().getStatusCode() == 200) { // 获得服务器端输出流 return EntityUtils.toString(httpRequest.getEntity()); } }catch(ClientProtocolException e){ e.printStackTrace(); }catch(UnsupportedEncodingException e){ e.printStackTrace(); }catch(IOException e){ e.printStackTrace(); }catch(Exception e){ e.printStackTrace(); }[/mw_shl_code]
查看原帖>>
01分享举报