Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我能用一个参数化的类型参数化一个ResponseEntity(Spring)吗?_Java_Spring Mvc - Fatal编程技术网

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);