SpringBoot (each的使用两种方式)
1.Controller
@RequestMapping("/success")
public String success(Map<String,Object> map){
map.put("hello","<h1>你好</h1>");
map.put("users", Arrays.asList("zhangsan", "lisi", "wangwu"));
return "success";
}
2.html中显示(thymeleaf框架)
<div th:text="${user}" th:each="user:${users}"></div>
<hr>
<div th:each="user:${users}">[(${user})]</div>
第一种输出方式是使用th:text
第二种输出方式是采用[(${user})], [(…)]相当于 th:utext
[[${text}]],[[…]]相当于th:text