springBoot默认模板引擎Thymeleaf简介

由于springBoot默认的是jar包形式,所以不支持,jsp。因此我们需要模板引擎。

JSP、Velocity、Freemarker、Thymeleaf模板引擎的大致原理:页面+数据交给模板引擎(写一个页面模板,里面一些值是动态的,我们用表达式形式,表达。例如下图中的template中的${user},数据来自Data),模板引擎通过数据解析表达式,写到对应位置。最终显示出去。

springBoot默认模板引擎Thymeleaf简介_第1张图片

市场上大概有5种,而spring默认选择Thymeleaf(语法更简单,功能更强大)

使用:

 1、引入thymeleaf;注意(默认的是2.1.6的版本)因此我们需要切换版本


            org.springframework.boot
            spring-boot-starter-thymeleaf
 

2.切换版本:注意,thymeleaf的主程序与layout版本的对应关系(3版本对应2)


        3.0.9.RELEASE
        
        2.2.2
 

 

你可能感兴趣的:(springBoot默认模板引擎Thymeleaf简介)