1 对象中包含list类型的参数
1.1 后端的数据类型
@Data
public class Answer implements Serializable {
private static final long serialVersionUID = 2939516508271512897L;
private List<Disk> disks;
}
1.2 Controlle层接收方式
@RequestMapping(value = "/getAnswer",method = RequestMethod.GET)
public void getAnswer(@RequestBody Answer answer)throws Exception{
System.out.println("======="+ JSON.toJSONString(answer));
System.out.println("this is good ");
return;
}
1.3 postMan参数设置
1.4 postMan 参数设置
{
"disks": [
{
"index": "1",
"type": "string"
},
{
"index": "2",
"type": "string"
}
]
}
1.5 结果验证
2 直接接收List类型的参数
2.1 后端接收参数类型 -- 同上
2.2 Controller层接收
@RequestMapping(value = "/getAnswers",method = RequestMethod.GET)
public void getAnswers(@RequestBody List<Answer> answers)throws Exception{
System.out.println("======="+ JSON.toJSONString(answers));
System.out.println("this is good ");
return;
}
2.3 postMan 参数设置 -- 同上
2.4 postMan 参数填写
[{
"disks":[{"index":"1","type":"string"},
{"index":"2","type":"string"}]
},
{
"disks":[{"index":"3","type":"string"},
{"index":"4","type":"string"}]
}
]
2.5 结果验证