[b]1、当只有一个属性需要返回时,可以在模型控制构造器中传入[/b]
[quote]
Date today = new Date();
return new ModelAndView("welcome","today",today);
[/quote]
2、如果有多个参数要返回,可以将他传递到一个Map中再来构造
[quote]
Map<String,Object> model = new HashMap<String,Object>();
return new ModelAndView("reservationQuery",model);
[/quote]
3.spring提供了ModelMap 可以根据模型属性的类型,自动生成模型属性的名称
ModelMap model = new ModelMap();
if(courtName != null){
model.addAttribute("courtName",courtName);
model.addAttribute("reservations",reservationService.query(courtName));
}
return new ModelAndView("reservationQuery",model);
[quote]
Date today = new Date();
return new ModelAndView("welcome","today",today);
[/quote]
2、如果有多个参数要返回,可以将他传递到一个Map中再来构造
[quote]
Map<String,Object> model = new HashMap<String,Object>();
return new ModelAndView("reservationQuery",model);
[/quote]
3.spring提供了ModelMap 可以根据模型属性的类型,自动生成模型属性的名称
ModelMap model = new ModelMap();
if(courtName != null){
model.addAttribute("courtName",courtName);
model.addAttribute("reservations",reservationService.query(courtName));
}
return new ModelAndView("reservationQuery",model);