002-05-RestTemplate 使用常见问题-非200请求捕获

一、概述

1.1、RestTemplate报错时时获取不到错误信息

捕获异常后

try {
            result = restTemplate.postForEntity(faceConfig.getApiUrl(), new HttpEntity<>(paramMap, getHttpHeaders()), String.class).getBody();
        } catch (HttpClientErrorException e) {
            result = e.getResponseBodyAsString();
        }

dd 

猜你喜欢

转载自www.cnblogs.com/bjlhx/p/11291358.html