当RestApi具有Spring的ResponseEntity <void>具有返回值时,它返回ClientProtocolExceptio

时间:2016-08-11 09:46:23

标签: java spring rest

我有一个RestApi暴露,在案件返回状态ok回到客户端。 方法的方法签名是ResponseEntity<void> methodName(){}。 这个方法是deleteApi。

在仅使用responseEntity创建的返回Status OK中,不会附加任何正文或任何其他标题详细信息。

在调用时我看到ClientProtocolException的日志中,看到当通过REST客户端(邮递员)执行相同操作时,在响应中收到了正确的Status OK消息。

  • ClientProtocolException被提出的原因是什么?

  • 如果返回类型为ResponeEntity<Void>,是否必须向其发送正文?

  • 如何避免上述异常?

代码:

 @RequestMapping(method = RequestMethod.DELETE)
public ResponseEntity<Void> methodName()
{
   // your buisness logic 
    return new ResponseEntity<Void>(HttpStatus.OK);
}

1 个答案:

答案 0 :(得分:0)

尝试如下

[5 6 7 8] is shape (4,)
[[5 6 7 8]] is shape (1, 4)
[[5 6 7 8]] is shape (1, 4)
[[5 6 7 8]] is shape (1, 4)