Java 我能用一个参数化的类型参数化一个ResponseEntity(Spring)吗?
我正在使用Java 我能用一个参数化的类型参数化一个ResponseEntity(Spring)吗?,java,spring-mvc,Java,Spring Mvc,我正在使用restemplate和springboot2.0 我有一个类,它表示对rest调用的自定义JSON响应 MyCustomResponse<T> { private T content; public T getContent() { return content; } } 因为我想测试一个票证对象 在这一行中,我可以使用反射来参数化响应,还是这是不可能的 ResponseEntity<MyCustomResponse>
restemplate
和springboot2.0
我有一个类,它表示对rest调用的自定义JSON响应
MyCustomResponse<T> {
private T content;
public T getContent() {
return content;
}
}
因为我想测试一个票证对象
在这一行中,我可以使用反射来参数化响应,还是这是不可能的
ResponseEntity<MyCustomResponse> response =
testRestTemplate.getForEntity(url, MyCustomResponse.class);
ResponseEntity响应=
getForEntity(url,MyCustomResponse.class);
我知道如何使用ResponseEntity
修复它,并将JSON解析到我的票据中。但我真正需要的是知道是否可以将此任务委托给restemplate
谢谢
ResponseEntity<MyCustomResponse> response =
testRestTemplate.getForEntity(url, RespostaPadrao.class);
Map< Map < String, Map < String, Map < String, Map < String, Integer >>>>>
ResponseEntity<MyCustomResponse> response =
testRestTemplate.getForEntity(url, MyCustomResponse.class);