我在我的前端使用Spring客户端设置。我是针对我的API进行身份验证,它返回以下内容
{
error: "unauthorized"
error_description: "User does not exist"
}使用我的rest客户端(Google : Advance ),也就是我使用Spring设置的expected.When,我期望错误对象RestClientException会在响应体中得到该JSON,但是它是空的。参见附加图像(监视控制台显示响应体中的内容)。

open image in new tab 右键单击图像并选择使图像变得更大
请求发送
grant_type=c_password&username=test&password=test&client_id=test&client_secret=test
响应
Date: Sun, 26 Apr 2015 20:59:45 GMT
Connection: close
Cache-Control: no-store
Pragma: no-cache
Www-Authenticate: Bearer realm="api/", error="unauthorized", error_description="User does not exist"
Content-Type: application/json;charset=UTF-8
Server: Jetty(7.x.y-SNAPSHOT)
Via: 1.1 vegur
Raw
JSON发布于 2015-04-27 12:40:35
这可能是一个RestTemplate错误--您的服务器(或代理)正在使用Connection: close和没有Content-Length头的组合。
确认这一点的一种方法是:让服务器编写内容长度标头(在Spring中,添加一个ShallowEtagHeaderFilter就可以做到这一点)。
如果这个解决方法解决了这个问题,那么这个错误已经在SPR-8016中修复了--将客户端应用程序升级到Spring4.1.5将解决这个问题。
https://stackoverflow.com/questions/29201655
复制相似问题