UriBuilder 错误地编码查询参数值?
让我们考虑以下代码示例,其中对路径和单个参数进行编码...
参数名称:“param”
参数值:“foo/bar?aaa=bbb&ccc=ddd”(恰好是带有查询参数的 url
String test = UriBuilder.fromPath("https://dummy.com").
queryParam("param", "foo/bar?aaa=bbb&ccc=ddd").
build().toURL().toString();
)返回的编码 URL 字符串是:
"https://dummy.com?param=foo/bar?aaa%3Dbbb&ccc%3Dddd"
这是正确的吗?
不应该是字符“&” (甚至可能是“?”)被编码在参数值字符串中?
生成的 URL 不会被解释如下:
第一个参数 name="param",value = "ar?aaa%3Dbbb" 后跟第二个参数 name="ccc%3Dddd",没有值。
Lets consider the following code sample where a path and single parameter are encoded...
Parameter name: "param"
Parameter value: "foo/bar?aaa=bbb&ccc=ddd" (happens to be a url with query parameters)
String test = UriBuilder.fromPath("https://dummy.com").
queryParam("param", "foo/bar?aaa=bbb&ccc=ddd").
build().toURL().toString();
The encoded URL string returned is:
"https://dummy.com?param=foo/bar?aaa%3Dbbb&ccc%3Dddd"
Is this correct ?
Should not the character "&" (and may be even "?") be encoded in the parameter value string ?
Would not the URL produced be interpreted as follow:
One first parameter, name="param", value = "ar?aaa%3Dbbb" followed by a second parameter, name="ccc%3Dddd", without value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对“fromPath”的最初调用可能应该是“fromUri”。那是说...
不,它看起来不像正确的输出。
是的,应该如此。
第一个参数是“foo/bar?aaa=bbb”,但是,是的,您解释得正确。这看起来像是 javax.ws.rs.core 提供程序中的错误。
Your initial call to "fromPath" should probably be "fromUri". That said...
No, it does not look like correct output.
Yes, it should be.
The first parameter would be "foo/bar?aaa=bbb", but yes, you're interpreting properly. This looks like a bug in your javax.ws.rs.core provider.