首页>代码>Spring Boot学习(四)之web开发渲染页面 -- Freemarker博客源码分享>/springbootstudy-demo4-freemarker/src/main/java/com/xiaojingg/web/HelloController.java
package com.xiaojingg.web; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 筱进GG */ @Controller public class HelloController { @RequestMapping("/hello") @ResponseBody public String hello() { return "Hello World"; } @RequestMapping("/") public String index(ModelMap map) { map.addAttribute("name", "筱进GG"); map.put("gender",1);//gender:性别,1:男;0:女; List<Map<String,Object>> friends =new ArrayList<Map<String,Object>>(); Map<String,Object> friend = new HashMap<String,Object>(); friend.put("name", "张三"); friend.put("age", 20); friends.add(friend); friend = new HashMap<String,Object>(); friend.put("name", "李四"); friend.put("age", 22); friends.add(friend); map.put("friends", friends); return "index"; } }

搁浅 LV1
2021年8月4日
xiaoche117 LV17
2020年6月19日
清咿酱 LV11
2020年5月7日
guaixia163 LV13
2020年2月27日
15237736357 LV2
2019年4月12日
低调人 LV38
2019年2月23日
Zrhans LV5
2019年2月22日
sgy1143 LV7
2018年7月27日
lw19900921 LV25
2018年7月4日
TwinkleQin LV6
2018年6月26日