Spring MVC 向页面传值

java:

 @RequestMapping("/test")
 public String test(Map<String,Object> map,Model model,ModelMap modelMap){
 
     map.put("names", Arrays.asList("caoyc","zhh","cjx"));
     model.addAttribute("time", new Date());
     modelMap.addAttribute("city", "ChengDu");
     modelMap.put("gender", "male");
     return "hello";
 }

jsp:
 1、time:${requestScope.time}
 <br/>2、names:${requestScope.names }
 <br/>3、city:${requestScope.city }
 <br/>4、gender:${requestScope.gender }

结果:

 

 


posted @ 2017-05-11 10:52  sunny^*^  阅读(210)  评论(0编辑  收藏  举报