Spring RestTemplate invoking webservice with errors and analyze status code

前端 未结 5 926
执笔经年
执笔经年 2020-12-07 17:39

I designed a webservice to perform a task if request parameters are OK, or return 401 Unauthorized HTTP status code if request parameters are wrong or empty.

I\'m us

5条回答
  •  臣服心动
    2020-12-07 18:46

    Since Spring 4.3, There is a RestClientResponseException which contain actual HTTP response data, such as status code, response body and headers. And you can catch it.

    RestClientResponseException Java Doc

提交回复
热议问题