如果形式“scheme:/ path”是URI有效吗?

问题描述 投票:0回答:1

我用这段代码在Java中创建URI:

new URI(/*scheme*/ "scheme", /*host*/ null, /*path*/ "/42", /*fragment*/ null);

当我将此URI转换为字符串时,我得到scheme:/42。格式为scheme:/path的URI是否有效?


当我使用new URI("scheme", "", "/path", null)时,我得到了scheme:///path。我知道这是有效的(如file:/// URI)。这些URI有不同的含义吗?

java uri
1个回答
1
投票

Wikipedia article on URIdiagram on Wikimedia Commons

URI = scheme:[//authority]path[?query][#fragment]

[…]

可以跳过//authority(用户+密码+主机+端口)部分。 path组件包括在/部分之后的//authority


此URI有效。

© www.soinside.com 2019 - 2024. All rights reserved.