为什么要thymeleaf?
SpringBoot不支持jsp,可以引入模板引擎来代替使用
JSP、Velocity、Freemarker、Thymeleaf等都是模板引擎
SpringBoot推荐我们使用Thymeleaf;
怎么引入?
在官方文档中找到场景启动器Starters
然后在pom.xml中引进来就可以了
<!--引入thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
maven会自动帮我们把jar包导进来,版本不用写它会自动识别
如果想切换版本:
在<properties>
标签中指明想要覆盖的版本就可以了
比如我想切换为3.0.9.RELEASE
这个版本,版本可以去GitHub
中看
<properties>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<!‐‐ 布局功能的支持程序 thymeleaf3主程序 layout2以上版本 ‐‐>
<!‐‐ thymeleaf2 layout1‐‐>
<thymeleaf‐layout‐dialect.version>2.2.2</thymeleaf‐layout‐dialect.version>
</properties>