【问题标题】:ResponseEntity.ok() without response body?ResponseEntity.ok() 没有响应主体?
【发布时间】:2020-08-13 17:27:08
【问题描述】:

我怎样才能返回一个带有 200 状态码且没有正文的 ResponseEntity?

我有一个 Http PUT 方法,我不想返回响应正文。我只想返回状态码。

【问题讨论】:

  • 您是否尝试将正文设置为null

标签: rest spring-rest


【解决方案1】:
@RequestMapping(method = RequestMethod.PUT, value = "/do/something")
public ResponseEntity doSomething() {
  return new ResponseEntity<>(null, HttpStatus.OK);
}

【讨论】:

    猜你喜欢
    • 2015-12-28
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 2016-05-08
    相关资源
    最近更新 更多