java.lang.IllegalArgumentException:索引 0 处的方案中的非法字符:本地主机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28114352/
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-11-02 13:01:07  来源:igfitidea点击:

java.lang.IllegalArgumentException: Illegal character in scheme at index 0: localhost

javalocalhostspring-android

提问by user3468921

I'am developping an android app that receive an data from server (localhost - mssql and nodejs), save data and then display it

我正在开发一个从服务器(本地主机 - mssql 和 nodejs)接收数据的 android 应用程序,保存数据然后显示它

after receiving the server response I get this error

收到服务器响应后,我收到此错误

I follow the instructions below enter link description hereinstead of the web server I use localhost. Thank you

我按照下面的说明在此处输入链接描述,而不是我使用 localhost 的 Web 服务器。谢谢

 Illegal character in scheme at index 0: 192.168.2.7:3000
    java.net.URISyntaxException: Illegal character in scheme at index 0: 192.168.2.7:3000
            at java.net.URI.validateScheme(URI.java:419)
            at java.net.URI.parseURI(URI.java:363)
            at java.net.URI.<init>(URI.java:204)
            at cz.uhk.fim.jedlima3.searchrooms.asyncTask.DownloadDatabaseAsync.doInBackground(DownloadDatabaseAsync.java:30)
            at cz.uhk.fim.jedlima3.searchrooms.asyncTask.DownloadDatabaseAsync.doInBackground(DownloadDatabaseAsync.java:15)
            at android.os.AsyncTask.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:864)

回答by vahid karimi

you should remove space from url and define scheme http or https

您应该从 url 中删除空间并定义方案 http 或 https

回答by Shubham

If you are Using localhost then pass url like this- http://localhost:8080/api/notesdefining scheme is important (http/https) do not use space also.

如果您使用 localhost,则像这样传递 url - http://localhost:8080/api/notes定义方案很重要(http/https)也不要使用空间。