如何返回json对象的列表,如{“items”:“[”{“”:“”},{“”:“”},...“]”}形成Spring MVC3.0?请帮助一下......
答案 0 :(得分:0)
@RequestMapping(value="/list", method=RequestMethod.GET)//, headers=ACCEPT_JSON)
@ResponseBody
public List<User> userList() {
LOG.info("get list of Users");
List<User> users = new ArrayList<User>();
users.add(new User("user1", "pass1", "name1", Boolean.TRUE));
users.add(new User("user2", "pass2", "name2", Boolean.TRUE));
users.add(new User("user3", "pass3", "name3", Boolean.TRUE));
return users;
}