URL url =URL(path); 这个语句老是在后面那个“URL”那报错,提示为The method URL(String) is undefined for…
照着视频敲得,没搞懂为什么会出错。
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.*;
import android.R.bool;
public class LoginService {
public static boolean loginByGet(String username,String password){
try {
String path ="http://192.168.1.100:8080/web/LoginServlet?username="+username+
"&password="+password;
URL url =URL(path);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
}
有人遇到过一样的情况吗
------解决思路----------------------
URL url =URL(path);
URL url =new URL(path);