当前位置: 代码迷 >> J2EE >> 没办法new URL了.该如何处理
  详细解决方案

没办法new URL了.该如何处理

热度:28   发布时间:2016-04-17 23:12:56.0
没办法new URL了....
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);
  相关解决方案