Thymeleaf是什么?
Thymeleaf是一个模板引擎,主要用于编写动态页面。存在的意义就是和spring框架集成!
Thymeleaf存在的意义和jsp是等价的
jsp中的数据是要转发后得到,Thymeleaf也要
jsp和Themleaf 相同点? 区别?
1. Thymeleaf 和Jsp很像都是做页面模板
2.Thymeleaf 和sp不同的地方
1.Thymeleaf 有单独的语法
2. Jsp允许直接访问但是Thymeleaf模板不允许必须通过 controller层的接口方法转发过去
如何使用Thymeleaf?
导入maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
注意:
springboot自动配置了Thymeleaf,默认在templates包下 默认有.html
源码: