【发布时间】:2015-12-13 11:50:36
【问题描述】:
这是代码
protected Void doInBackground(String... params) {
String reg_url = "http://10.0.2.2/";
String method = params [0];
if (method.equals("register") ){
String first_name = params [1];
String last_name = params [2];
String address = params [3];
String email = params [4];
String password = params [5];
try {
URL url = new URL(reg_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
HttpURLConnection.setRequestMethod("POST");
HttpURLConnection.setDoOutput(True);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
我在这两行得到了错误
HttpURLConnection.setRequestMethod("POST");
HttpURLConnection.setDoOutput(True);
关于 set.RequestMethod("POST") 和 "setDoOutput(true); 错误说不能从静态上下文中引用非静态方法。 这一定是个愚蠢的错误,但我就是想不通,所以有人可以帮我解决这个问题吗?
【问题讨论】:
-
感谢所有帮助我解决问题的三位成员。你是最棒的
-
以后请搜索类似问题。这个问题每周至少被问 5 到 10 次,我不认为该网站会从再添加一个中受益。例如:simple search on error message.
标签: java methods non-static