我正在使用spring和hibernate开发一个restful应用程序。我发布这个JSON {
"name": "Test Category",
"parent": 2
}由此,我无法在我的控制器post方法中获取父ID。当我使用theCategory.getParent()时,它返回null。这是我的控制器发布方法。@PostMapping("/categories")public Category addCategory(@RequestBody Category theCategory) {
System.out.println("The parent category : " + theCategory.getParent());
// set id to 0
theCategory.setId(0);
categoryService.saveCategory(theCategory);
return theCategory;}当我保存类别时,设置父类别的最佳方法是什么?这是我的类别类 - https://github.com/iyngaran/test/blob/master/Category.java
添加回答
举报
0/150
提交
取消