且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Jersey Client 2中编码花括号

更新时间:2022-12-26 22:13:08

当你创建一个卷曲值为的参数时,泽西岛认为你想使用URL参数。请参阅 https://jersey.java.net/documentation/latest/uris -and-links.html

When you create a parameter with a value in curly, Jersey thinks you want to use a URL parameter. See https://jersey.java.net/documentation/latest/uris-and-links.html.

UriBuilder.fromUri("http://localhost/")
 .path("{a}")
 .queryParam("name", "{value}")
 .build("segment", "value");

所以你应该通过URLEncoder对花括号进行编码,可能如下所述:如何强制URIBuilder.path(...)编码像%AD这样的参数?此方法并不总是正确编码百分比参数

So you should encode curly braces yourselves via URLEncoder, probably as described there: How to force URIBuilder.path(...) to encode parameters like "%AD"? This method doesn't always encode parameters with percentage, correctly.