Jersey ClientResponseLocation
从标题中获取:
/**
* Get the location.
*
* @return the location, otherwise <code>null</code> if not present.
*/
public URI getLocation() {
String l = getHeaders().getFirst("Location");
return (l != null) ? URI.create(l) : null;
}
JAX-RS 响应通过以下方式提供标头信息getMetadata()
:
public MultivaluedMap<String, Object> getMetadata() {
if (headers != null)
return headers;
headers = new OutBoundHeaders();
for (int i = 0; i < values.length; i++)
if (values[i] != null)
headers.putSingle(ResponseBuilderHeaders.getNameFromId(i), values[i]);
Iterator i = nameValuePairs.iterator();
while (i.hasNext()) {
headers.add((String)i.next(), i.next());
}
return headers;
}
所以我会尝试的是:
response.getMetadata().getFirst("Location");
(如果这不起作用打印元数据内容。也许密钥有另一个名称。)