post多个参数

HttpPost httpPost = new HttpPost(ADDCONVENTION+"?");
                String mobile = EightPartyApplication.systemShared.getString(
                        EightPartyApplication.MOBILE, "");
                
                String ks = EightPartyApplication.systemShared.getString(
                        EightPartyApplication.KEYPHONE, "");
                
                        StringBuilder sbu = new StringBuilder();
                        sbu.append(URLEncoder.encode(sTitle,"UTF-8")).append(";").append(sTime).append(";")
                        .append(URLEncoder.encode(sEmcee,"UTF-8")).append(";").append(sEightNum).append(";")
                        .append(password);

                StringBuilder sbd = new StringBuilder();

                for (int i = 0; i < list.size(); i++) {
                    sbd.append(list.get(i).getPhoneNum())
                            .append(",")
                            .append(URLEncoder.encode(list.get(i).getDisplayName(),
                                    "UTF-8")).append(";");
                }
                
                // 设置HTTP POST请求参数必须用NameValuePair对象
                List parms = new ArrayList();
                parms.add(new BasicNameValuePair("key", ks));
                parms.add(new BasicNameValuePair("mobile",mobile));
                parms.add(new BasicNameValuePair("content", sbu.toString()));
                parms.add(new BasicNameValuePair("member", sbd.toString()));
                parms.add(new BasicNameValuePair("timestamp", longtimes+""));
                parms.add(new BasicNameValuePair("identifier", tab_id+""));
                for (int i = 0; i < parms.size(); i++) {
                    System.out.println(parms.get(i).getName()+" : "+parms.get(i).getValue());
                }
                Log.i(TAG,"result, 1 , ks = "+ks+" \t "+mobile+" \t "+sbu.toString()+" \t "+sbd.toString()+" \t "+longtimes+" \t "+tab_id);
                HttpResponse httpResponse = null;
                    // 设置httpPost请求参数
                    httpPost.setEntity(new UrlEncodedFormEntity(parms, HTTP.UTF_8));
                    httpResponse = new DefaultHttpClient().execute(httpPost);
                     System.out.println("resultcode = "+httpResponse.getStatusLine().getStatusCode());
                    if (httpResponse.getStatusLine().getStatusCode() == 200) {
                        // 第三步,使用getEntity方法得返回结果
        
                        String result = EntityUtils.toString(httpResponse.getEntity());
                        System.out.println("result2 = "+result);
                    }

你可能感兴趣的:(多个参数post连接服务器,android,post多个参数)