例子中使用UserInfo和UserMsg两个类,具体如下
UserInfo.java
@Getter
@Setter
public class UserInfo implements Serializable{
private String userName;
private List<UserMsg> msgList;
}
UserMsg.java
@Getter
@Setter
public class UserMsg implements Serializable{
private String title;
private String text;
}
1、JSON格式传递List
Cotroller类
@RestController
@RequestMapping("/test")
public class TestController {
@PostMapping(value="list")
public void getDeleteChosen(@RequestBody UserInfo userInfo) {
System.out.println(userInfo.toString());
}
}
postman