java - 为什么请求正文总是空的?
问题描述
我正在尝试创建简单的 spring CRUD,但是创建的发布请求总是空的。如果我手动填充对象 - 一切正常:
@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
我这样发送请求一样异常Postman
:
感谢任何帮助!
解决方案
默认property-naming-strategy
值为LOWER_CAMEL_CASE
.
在 lowerCamelCase 中命名您的 JSON 属性,如下所示:
{
"userId": 1,
"issueId": 483162,
"comment": "comment"
}
推荐阅读
- eclipse - 如何获取在 Eclipse 的活动 Eclipse 编辑器窗口中打开的文件列表?
- sql - 算术溢出 - 处理溢出的情况
- java - (Java) 按字母顺序排列的二叉树类不能按预期工作
- java - 如何在值(或路径)内使用 { 和 @RequestMapping
- python - 带有动态列表的下拉 Django
- caching - 如何利用浏览器缓存 URL?
- angular - 从 Angular 生产版本中删除 QA 属性
- javascript - 如何在node.js中将类似字符串的数组转换为数组?
- php - 422 Unprocessable Entity Laravel 5.6 AJAX请求使用请求规则返回json中的响应
- javascript - 如何在 ionic 3 angular 4 中停止重新加载页面