想知道是否有人可以帮助我。我有一个 JSON 请求{ "blue": "blue", "red": "red", "greens" : { "lightGreen": "lightGreen", "darkGreen": "darkGreen" }}我想映射到pojo使用@RequestBody这样做:@PostMapping(path = "/colors", headers = "Accept=application/json")public void generateClaimDocument(@Valid @RequestBody Colors colors) { if (colors != null) { service.doSomethingWithColors(colors); } }这适用于蓝色和红色,但它根本没有映射 JSON 绿色对象。以前从未这样做过,所以有人可以阐明我如何做到这一点吗?波乔:public class Colors { private String blue; private String red; private Greens greens; //getters and setters}public class Greens { private String lightGreen; private String darkGreen; //getters and setters}
添加回答
举报
0/150
提交
取消