0

我需要向服务器发送一个字符串,但我知道的唯一方法是使用名称值对,但这会发送密钥和值,我只想发送一个字符串,我该怎么做?

HttpClient httpclient = new DefaultHttpClient();
                        HttpPost httppost = new HttpPost("http://10.0.2.2:1455/Android/Android.svc/GetCompanyBusinessAreas");


                        try 
                        {           
                         List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                         nameValuePairs.add(new BasicNameValuePair("", companhiaIdS));




                         httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                         Log.i("Enviando:", nameValuePairs.toString());


                        // Execute HTTP Post Request
                            HttpResponse response = httpclient.execute(httppost);
                            Log.i("Resposta:", response.getEntity().toString());
                            HttpEntity responseEntity = response.getEntity();

我可以用什么代替namevaluepairs,因为它发送一个列表而服务器只需要一个字符串?

4

1 回答 1

1
httppost.setEntity(new StringEntity("your string"));
于 2013-05-07T14:53:38.020 回答