我有一个自定义通用方法,它GET向 URL 发出请求并将 JSON 响应转换为responseType对象:
public static <T> Object getForEntity(String url, Class<T> responseType) throws InterruptedException, ExecutionException, IOException{
Response getResponse = callWithHttpGet(url);
String getResponseJson = getResponse.getBody();
ObjectMapper getResponseJsonMapper = new ObjectMapper();
Object obj = getResponseJsonMapper.readValue(getResponseJson, responseType);
return obj;
}
如果我将其称为如下代码,则上面的代码可以正常工作:
Object person = getForEntity(PERSON_REST_URL,Person.class);
如何使其如下工作而不是返回对象?
Person person = getForEntity(PERSON_REST_URL, Person.class);
慕工程0101907
慕后森
白板的微信
相关分类