java.lang.IllegalArgumentException:发出 https 请求时索引 7 处的非法字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18295759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 00:11:19  来源:igfitidea点击:

java.lang.IllegalArgumentException: Illegal character in authority at index 7 while making https request

javaandroidandroid-emulatorwampserver

提问by sandeep_jagtap

While making http request to my local wamp server from android emulator I got above error.

从 android 模拟器向我的本地 wamp 服务器发出 http 请求时,我遇到了上述错误。

// testing on Emulator:
private static final String LOGIN_URL="http:// 10.0.2.2:80/webservice/login.php";

//request:
JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params);

采纳答案by Ye Lin Aung

You have a space at index 7 of your string LOGIN_URLand it is causing the exception. It should be like this.

您在字符串的索引 7 处有一个空格,LOGIN_URL它导致了异常。应该是这样的。

LOGIN_URL = "http://10.0.2.2:80/webservice/login.php"

回答by sandeep_jagtap

I found the answer:
After googling for couple of hours I found that this kind of error occur due to problem in url
I had extra space in my URL which I removed and I got everything working

我找到了答案:
在谷歌搜索几个小时后,我发现这种错误是由于 url 中的问题而发生的
,我删除了 URL 中的额外空间,并且一切正常

    // testing on Emulator:
    private static final String LOGIN_URL = "http://10.0.2.2:80/webservice/login.php";