JAVA全系列 教程
3762个小节阅读:7095.4k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
SpringMVC不支持将参数封装为对象类型的List集合,但可以封装到有List属性的对象中。
编写实体类
xxxxxxxxxx
public class Student {
private int id;
private String name;
private String sex;
private List<Address> address; // 地址集合
// 省略getter/setter/tostring
}
编写控制器方法
xxxxxxxxxx
// 对象中包含集合属性
@RequestMapping("/c1/param6")
public void listParam3(Student student){
System.out.println(student);
}
请求的参数写法
1. 在SpringMVC中,接受简单数据类型List参数,必须在方法参数前加
A @RequestParam
B @Param
C @Value
D @List
2. SpringMVC不支持封装对象类型的List参数,但可以封装
A 包含List的数组
B 包含List的Map集合
C 包含List的Collection集合
D 有List属性的对象
1=>A 2=>D