1、
// The wrapper class, so that type info (of User) is passed thru the message converters to Jackson
public class Users extends ArrayList<User> {
private static final long serialVersionUID = 1L;
public Users() { super(); }
}
// Example method from the controller:
@RequestMapping(value="/status", method = RequestMethod.POST)
public @ResponseBody Map<String, ? extends Object> status(@RequestBody Users users) {
// handle the request here
}
2、使用数组替代
3、spring 3.2 直接支持泛型集合
https://jira.springsource.org/browse/SPR-9570
sprng3.2支持如List<Sample> Map<String, Sample>等集合泛型。
本文详细介绍了如何在Spring 3.2 MVC中实现请求体反序列化自定义集合对象的方法,包括使用自定义包装类传递类型信息给消息转换器到Jackson,以及通过数组替代、直接支持泛型集合等功能。
1182

被折叠的 条评论
为什么被折叠?



