//1、使用ModelAndView传值(普通值和map集合)
@RequestMapping("/test1")
public ModelAndView test1(ModelAndView m) {
m.addObject("str", "你好");
Map map = new HashMap();
map.put("name", "坤");
m.addAllObjects(map);
m.setViewName("test");
return m;
}
2、使用Model传值
//2、使用Model传值
@RequestMapping("/test2")
public String test2(Model m) {
m.addAttribute("str", "你好");
Map map = new HashMap();
map.put("name", "坏");
m.addAllAttributes(map);
return "test";
}
2、使用普通对象(javabean对象传值)默认提示根据配置返回的jsp页面
//3、使用普通对象(javabean对象传值)默认提示根据配置返回的jsp页面
@RequestMapping("/test3")
public User test3() {
User user = new User("123", "123");
return user;
}
@RequestMapping("/test4")
@ResponseBody
public User test4() {
User user = new User("123", "123");
return user;
}