簡體   English   中英

為什么請求體總是空的?

[英]Why request body is always empty?

我正在嘗試創建簡單的 spring CRUD,但是創建的 post 請求總是空的。 如果我手動填充對象 - 一切正常:

 @ResponseBody
 public Comment createOrUpdateComment(@RequestBody Comment comment) {

 comment.setIssueId(new Long(483162));
 comment.setUserId(new Long(2));
 comment.setComment("Comment");

 Comment updated = service.createOrUpdateComment(comment);
      return updated;
 }

沒有手動設置 - 對象始終為空,並且無法像Column 'issue_id' cannot be null這樣的異常Column 'issue_id' cannot be null我正在向Postman發送請求,如下所示:

請求示例

感謝任何幫助!

默認的property-naming-strategyLOWER_CAMEL_CASE

將您的 JSON 屬性以 lowerCamelCase 命名,如下所示:

{
    "userId": 1,
    "issueId": 483162,
    "comment": "comment"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM