【发布时间】:2011-07-14 14:44:07
【问题描述】:
我正在尝试通过使用 post 方法发送用户名和密码来向 url 发布帖子。但答案尚不清楚。
这是我的做法:
HttpClient httpclient =new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://test.res-novae.fr/xperia_orange/scripts/android_ckeck_user.php");
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
/*Checking response*/
if(response!=null)
{
InputStream in = response.getEntity().getContent();
System.out.println("Resultat de la server:"+in);
}
}
catch(ClientProtocolException e)
{
}
catch (IOException e) {
// TODO Auto-generated catch block
}
这是来自服务器的答案:
Resultat de la server:org.apache.http.conn.EofSensorInputStream@44e067e0
有谁知道我做错了什么?
【问题讨论】: