Java 来自字符串的WebTarget

Java 来自字符串的WebTarget,java,rest,url,jersey-client,Java,Rest,Url,Jersey Client,我正在通过Jersey客户端使用RESTAPI。API已分页 Client client = ClientBuilder.newClient() .register(HttpAuthenticationFeature.basic(USER_NAME, PASSWORD)); WebTarget target = client.target(HOST).path(API_BASE).path("content"); PageResult pageResult = target.r

我正在通过Jersey客户端使用RESTAPI。API已分页

Client client = ClientBuilder.newClient()
        .register(HttpAuthenticationFeature.basic(USER_NAME, PASSWORD));

WebTarget target = client.target(HOST).path(API_BASE).path("content");
PageResult pageResult = target.request(JSON).get()readEntity(PageResult.class);
响应如下所示:

{
    "results":[...
    ],
    "start": 0,
    "limit": 25,
    "size": 25,
    "_links": {
        "self": "http://localhost:8090/rest/api/content",
        "next": "/rest/api/content?limit=25&start=25",
        "base": "http://localhost:8090",
        "context": ""
    }
}
pageResult对象已正确填充响应。 现在我想创建一个新的WebTarget或重用当前的WebTarget。更改的是查询参数

创建新WebTarget的最简单方法是什么

这样就无法正确解释查询参数。我也不想自己解析url。有什么API?我可以手动添加查询参数,但我认为应该有一种方法,如WebTarget.fromStringpageResult.\u links.base+pageResult.\u links.next

更改行

target = client.target(pageResult._links.base).path(pageResult._links.next);

来自doku

/**
 * Build a new web resource target.
 *
 * @param uri web resource URI. May contain template parameters. Must not be {@code null}.
 * @return web resource target bound to the provided URI.
 * @throws IllegalArgumentException in case the supplied string is not a valid URI template.
 * @throws NullPointerException     in case the supplied argument is {@code null}.
 */
public WebTarget target(String uri);
target = client.target(pageResult._links.base + pageResult._links.next)
/**
 * Build a new web resource target.
 *
 * @param uri web resource URI. May contain template parameters. Must not be {@code null}.
 * @return web resource target bound to the provided URI.
 * @throws IllegalArgumentException in case the supplied string is not a valid URI template.
 * @throws NullPointerException     in case the supplied argument is {@code null}.
 */
public WebTarget target(String uri);