[英]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-strategy
是LOWER_CAMEL_CASE
。
將您的 JSON 屬性以 lowerCamelCase 命名,如下所示:
{
"userId": 1,
"issueId": 483162,
"comment": "comment"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.