我试图从android模拟器发送数据到运行在本地主机上的servlet,我有以下代码,但它不发送数据到servlet。我也试过我的ip "192.168.2.15:8080“而不是"10.0.2.2:8080”,但结果是一样的,有人能告诉我我哪里错了吗?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://10.0.2.2:8080/Interactive_ICS_Web/datareciever");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", "naveed"));
nameValuePairs.add(new BasicNameValuePair("password", "12345"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
https://stackoverflow.com/questions/12549728
复制相似问题