发送整数到HTTP服务器我想从我的Android客户端使用该NameValuePair
方法的几个值发送到Web服务器:使用的NameValuePair
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http:/xxxxxxx");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
String amount = paymentAmount.getText().toString();
String email = inputEmail.getText().toString();
nameValuePairs.add(new BasicNameValuePair("donationAmount", amount));
nameValuePairs.add(new BasicNameValuePair("email", email));
nameValuePairs.add(new BasicNameValuePair("paymentMethod", "5"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
可惜NameValuePair
只能够发送字符串,我需要也发送整数值。任何人都可以帮我解决我的问题吗?
我有与象不同势名称微调五个值,B,C,d,E,连接要通过这串values..how的整数值做呢?<字符串数组名=“planets_array”> <项目值= “1”>一个 <项目值= “2”> b <项目值= “3”>ç <项目值= “4”> d <项目值=“5 “e- f
string-array> –
2014-11-04 12:10:30
@AdityaVyas,在新帖子中提出一个新问题。 – 2014-11-17 00:06:19
它只是从微调获取选定值的问题。然后你可以使用Integer.toString()方法将Integer转换为String。 @DarylBennett是正确的你的问题是不相关的这个线程。 – 2014-11-17 05:41:35