RestTemplate - Handling response headers/body in Exceptions (RestClientException, HttpStatusCodeException)
问题 In my restful webservice, in case of bad request (5xx) or 4xx respose codes, I write a custom header "x-app-err-id" to the response. On the client side, I use exchange method of RestTemplate to make a RestFul web service call. Everything is fine when the response code is 2xx. ResponseEntity<Component> response = restTemplate.exchange(webSvcURL, HttpMethod.POST, requestEntity, Component.class); But if there is an exception(HttpStatusCodeException) because of it being a bad request(5xx) or 4xx,