SpringBoot--->Thymeleaf模板引擎
2021-06-11 04:03
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:doc dep ref set *** tar mod 官方文档 use
1、导入依赖
org.thymeleaf thymeleaf-spring5org.thymeleaf.extras thymeleaf-extras-java8time
只要导入对应的依赖,
2、练习使用Thymeleaf
1、在对应HTML页面导入相关依赖
对应HTML页面需要取值,使用 th:***="${+++}" 获取
Title
2、在对应controller里跳转
@Controller public class HelloController { @RequestMapping("/test") public String test(Model model) { model.addAttribute("msg","hello,springboot"); return "test"; } }
3、练习使用数据填充
[[ ${user} ]]
2、对应的controller
public class HelloController { @RequestMapping("/test") public String test(Model model) { model.addAttribute("msg","hello,springboot
"); model.addAttribute("users", Arrays.asList("xian","Spring")); return "test"; } }
文字过多,需要时及时翻看官方文档
Thymeleaf 官网:https://www.thymeleaf.org/
Thymeleaf 在Github 的主页:https://github.com/thymeleaf/thymeleaf
Spring官方文档:找到我们对应的版本
https://docs.spring.io/spring-boot/docs/2.2.5.RELEASE/reference/htmlsingle/#using-boot-starter
Thymeleaf模板引擎,soscw.com" target="_blank">SpringBoot--->Thymeleaf模板引擎
标签:doc dep ref set *** tar mod 官方文档 use
原文地址:https://www.cnblogs.com/springxian/p/14237397.html
文章标题:SpringBoot--->Thymeleaf模板引擎
文章链接:http://soscw.com/index.php/essay/93423.html