Spring boot 为什么restTemplate.exchange的响应返回null?
我有blow代码,我的web服务运行良好,但没有返回响应:Spring boot 为什么restTemplate.exchange的响应返回null?,spring-boot,exception-handling,spring-rest,spring-web,Spring Boot,Exception Handling,Spring Rest,Spring Web,我有blow代码,我的web服务运行良好,但没有返回响应: ResponseEntity<Object> reponse=null; try { reponse = restTemplate.exchange(url, HttpMethod.POST, requestEntity, Object.class); } catch (HttpStatusCodeException e) { System.o
ResponseEntity<Object> reponse=null;
try {
reponse = restTemplate.exchange(url, HttpMethod.POST, requestEntity, Object.class);
} catch (HttpStatusCodeException e) {
System.out.println("reponse="+reponse);
}
ResponseEntity-response=null;
试一试{
reponse=restemplate.exchange(url、HttpMethod.POST、requestEntity、Object.class);
}捕获(HttpStatusCodeException){
System.out.println(“reponse=“+reponse”);
}
我的问题是,,
为什么
响应
为空,但
restemplate.exchange(url、HttpMethod.POST、requestEntity、Object.class)
是否不为空?我在响应实体中错误地搜索错误。但它在例外情况下可用
} catch (HttpClientErrorException e) {
System.out.println(e.getStatusCode());
System.out.println(e.getResponseBodyAsString());
}
在主题中使用正确的大小写转换,并阅读“如何提问”。