简体   繁体   English

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

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

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);

You have a space at index 7 of your string LOGIN_URL and it is causing the exception.您的字符串LOGIN_URL索引 7 处有一个空格,它导致了异常。 It should be like this.应该是这样的。

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

I found the answer:我找到了答案:
After googling for couple of hours I found that this kind of error occur due to problem in url谷歌搜索几个小时后,我发现这种错误是由于 url 问题而发生的
I had extra space in my URL which I removed and I got everything working我的 URL 中有多余的空间,我已将其删除,然后一切正常

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

For me it was a new line character at the end of the url String.对我来说,它是 url 字符串末尾的换行符。 It wasn't really visible to the naked eye but I caught it with Vi.肉眼无法真正看到它,但我用 Vi 捕捉到了它。 Pretty dumb error message, not at all helpful.非常愚蠢的错误消息,一点帮助都没有。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:java.lang.IllegalArgumentException:索引 120 处查询中的非法字符 - Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 120 java.lang.IllegalArgumentException:方案中索引0处的非法字符: - java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 原因:java.lang.IllegalArgumentException:索引72的查询中的非法字符 - Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 72 java.lang.IllegalArgumentException:索引59处查询中的非法字符 - java.lang.IllegalArgumentException: Illegal character in query at index 59 java.lang.IllegalArgumentException:索引 0 处方案中的非法字符:localhost - java.lang.IllegalArgumentException: Illegal character in scheme at index 0: localhost java.lang.IllegalArgumentException:索引33路径中的非法字符:https://box.one.th/app/api/upload - java.lang.IllegalArgumentException: Illegal character in path at index 33: https://box.one.th/app/api/upload 获取java.lang.IllegalArgumentException:非法模式字符'o'? 在解析java.text.SimpleDateFormat时 - getting java.lang.IllegalArgumentException: Illegal pattern character 'o'? while parsing java.text.SimpleDateFormat http连接中的错误java.lang.IllegalArgumentException:索引76处的查询中的非法字符 - Error in http connection java.lang.IllegalArgumentException: Illegal character in query at index 76 JBoss登录Web应用程序错误-无法解析请求。java.lang.IllegalArgumentException:查询中的非法字符 - JBoss Login Web Application error - Failed to parse request.: java.lang.IllegalArgumentException: Illegal character in query 格式化参数“” java.lang.IllegalArgumentException时发生异常:非法模式字符“ T” - Exception while formatting the parameter“ ”java.lang.IllegalArgumentException: Illegal pattern character 'T'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM