【问题标题】:java.lang.IllegalArgumentException: Illegal character in scheme at index 0: localhostjava.lang.IllegalArgumentException:索引 0 处的方案中存在非法字符:localhost
【发布时间】:2015-03-22 18:06:43
【问题描述】:

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

收到服务器响应后出现此错误

我遵循enter link description here 下面的说明,而不是我使用 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$2.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$1.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)

【问题讨论】:

  • 请附上代码。
  • 这确实不是一个有效的 URI;在您的配置文件中的某处或您放置192.168.2.7:3000 的任何位置,这不是有效的URI;你可能是说http://192.168.2.7:3000

标签: java localhost spring-android


【解决方案1】:

确保您的网址没有拼写错误,http:// 或 https://

【讨论】:

    【解决方案2】:

    您应该从 url 中删除空格并定义方案 httphttps

    【讨论】:

      【解决方案3】:

      当我们使用在本地机器上运行的任何服务时,请尝试使用 http 协议而不是直接调用服务来调用服务。 示例:localhost:1234/hello(错误会给出上述异常) http://localhost:1234/hello(correct路)

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-01-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-03-26
          • 2013-08-20
          • 2016-11-02
          相关资源
          最近更新 更多