uriBuilder returns http:// 而不是 http://

uriBuilder returns http:/ instead of http://

我使用这个代码:

UriBuilder builder = UriBuilder
        .fromPath(Constants.LIVEMAP_BASE_URL_US)
        .scheme("http");
return builder.build().toString();

怎么会生成了"http:/"而不是"http://"

返回值=http:/livemap-tiles1.waze.com/tiles/internal?lineGeom=...

您在滥用 fromPath。该方法需要 uri 路径,但您提供的是主机和路径。

如果您有完整的 URI,请使用 UriBuilder#fromUri,否则逐个构建它

UriBuilder builder = UriBuilder.fromPath("tiles")
                               .host("livemap-tiles1.waze.com")
                               .scheme("http")
                               .path("internal"); // etc.