【发布时间】:2011-05-03 07:30:37
【问题描述】:
我想通过android中的POST方法向服务器发送一些数据。我正在使用以下代码
DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("name", "value"));
nameValuePairs.add(new BasicNameValuePair("password", "value"));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response=hc.execute(postMethod,res);
但我在响应 xml 中收到错误响应。错误消息是客户端计算机中禁用了 cookie。我如何需要在 android 中启用 cookie?
【问题讨论】:
-
请将您的代码放入代码块中。