处理方法返回值
1.Object
@RequestMapping("/first") @ResponseBody public Object doOne(){ return 1; } @RequestMapping(value = "/second",produces = "text/html;charset=utf-8") @ResponseBody public Object sss(){ return "黑夜"; } @RequestMapping(value = "/three") @ResponseBody public Object ssss(){ UserInfo info=new UserInfo(); info.setName("aaaa"); return info; }
2.Object--map
@RequestMapping(value = "/four") @ResponseBody public Object s2(){ Map<String,UserInfo> map=new HashMap<String, UserInfo>(); UserInfo info=new UserInfo(); info.setName("aaaa"); info.setAge(12); UserInfo info1=new UserInfo(); info1.setName("aaaaa"); info1.setAge(122); map.put(info.getName(),info); map.put(info1.getName(),info1); return map; }
3.Object--List
@RequestMapping(value = "/five") @ResponseBody public Object dofive(){ List<UserInfo> list=new ArrayList<UserInfo>(); UserInfo info=new UserInfo(); info.setName("aaaa"); info.setAge(12); list.add(info); return list; }