【发布时间】:2014-01-11 06:21:51
【问题描述】:
我有一个 Android 应用程序尝试使用 HttpUrlConnection 向我的服务器发出 GET 请求。当我在单独的测试桌面应用程序中测试代码时,一切正常。但是,当我在我的 android 设备上运行它时,我的服务器会注册一个 POST 请求而不是 GET。
这是我的get 方法的代码:
public static String get(String url) throws IOException {
HttpURLConnection conn = connFromUrlString(url);
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
String out = IOUtils.toString(conn.getInputStream(), "UTF-8");
conn.disconnect();
return out;
}
【问题讨论】:
标签: android http post get httpurlconnection