- thymeleaf语法
-
1.th:utext,转义文本
- controller
model.addAttribute("msg","<h1>hello,springboot!</h1>");
- html
<div th:text="${msg}"></div>
<div th:utext="${msg}"></div>
测试结果:
- 2.遍历数据
- controller
model.addAttribute("users", Arrays.asList("bill","tom"));
- html
<h1 th:each="user:${users}" th:text="${user}"></h1>
测试结果
标签:SpringBoot,50,addAttribute,230124,controller,html From: https://www.cnblogs.com/wcwblog/p/17066321.html