我在Android应用程序中有以下代码:
public static HttpResponse dbPost(String handlerUrl, List postData) {
HttpClient httpclient = new DefaultHttpClient();
String postUrl = constants.postUrl();
HttpPost httppost = new HttpPost(postUrl);
HttpResponse response = null;
System.out.print("Catch 0");
try {
httppost.setEntity(new UrlEncodedFormEntity(postData));
response = httpclient.execute(httppost);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.print("Catch 1");
return response;
}我有一个调用这个块的按钮。如果按下按钮,控制台将打印“Catch 0”(但不是“Catch 1”)。如果我再次按下按钮(同一实例),控制台将打印“Catch1Catch0”。有什么问题?
我对Java有点新,所以请耐心等待。