import org.apache.http.message.BasicNameValuePair;
private String getServerData(String returnString) {
InputStream is = null;
String result = "";
//the year data to send
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("year","1970"));
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(KEY_121);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}
}
私の質問...誰も私にこのコードを説明できますか?
BasicNameValuePairクラスは何をするのでしょうか?
ラインのこの作品は
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
がis = entity.getContent();
は何をするのか何をしますか?私はBasicNameValuePairクラスで複数の値を渡すことができます。これの代わりに私は完全にVOを渡すことができますか?最終的には以下のように
nameValuePairs.add(new BasicNameValuePair("year","1970","sas","saassa","sas","asas"));
私の質問を更新しました – theJava
...答えとしてマークするのを忘れないでください;) – Mascarpone