前台:
const postData = new FormData();
let checklist = [一些数组值];
for (let i = 0; i < checklist.length; i++) {
postData.append("orders[" + i + "].id", checklist[i].id);
postData.append("orders[" + i + "].type", checklist[i].type);
postData.append("orders[" + i + "].name", checklist[i].name);
//下面这种方式后台接收不到
postData.append("orders[" + i + "]", checklist[i]);
}
后台:
//controller接收
@ModelAttribute("userForm") User userForm
//实体类映射
public class User {
private List<Order> orders;
}