数据传递,网页模板thymeleaf
springboot
网页模板thymeleaf
POM配置:
org.thymeleaf thymeleaf-spring5 org.thymeleaf.extras thymeleaf-extras-java8time
模板页配置:
转意用utext(不是文本)
后台:
public String test(Model model) {
model.addAttribute("msg", "html.chen
");
return "/test";
}
获取数组:
<h3 th:each="user:${users}" th:text="${user}">h3>
model.addAttribute("users", Arrays.asList("chen","li"));
在标签内插入数据
<h3 th:each="user:${users}">[[${user}]]h3>