我正在编写一个 Android 应用程序。当我使用时,它会向服务器发送 HTTPPost 并接收答案:
public final HttpResponse execute (HttpUriRequest request)
没关系,
但是当我尝试使用时:
public T execute (HttpUriRequest request, ResponseHandler<? extends T> responseHandler)
它抛出ClientProtocolException
由于某些原因我想使用第二个功能,我该怎么办?有什么例外?
这是使用第一个函数的代码:
HttpPost httppost = new HttpPost("http://foo.Com/GeneralControls/Service.asmx/Login");
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost) ;
这是使用第二个函数的代码:
HttpPost httppost = new HttpPost("http://foo.Com/GeneralControls/Service.asmx/Login");
DefaultHttpClient httpclient = new DefaultHttpClient();
ResponseHandler<String> responseHandler=new BasicResponseHandler();
String response = httpclient.execute(httppost , responseHandler) ;
抛出 ClientProtocolException。