码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-08-02 22:23:33      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:conf   ror   rest   body   except   报错   exce   new   tpc   

一、概述

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

捕获异常后

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

 

 

dd 

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

标签:conf   ror   rest   body   except   报错   exce   new   tpc   

原文地址:https://www.cnblogs.com/bjlhx/p/11291358.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!