课程4_Spring Boot模版引擎和模版语法

3.3 Spring Boot模版引擎调用

模板引擎,是用来生成动态网页内容的,一旦控制器(Controller)收集了足够的数据,就会把数据交给模板引擎来处理,模板引擎根据数据生成HTML,返回给浏览器。
      Spring Boot支持多种模板引擎,包括FreeMarker、Thymeleaf、Mustache和Groovy Templates。Spring Boot中不推荐使用jsp,Thymeleaf现在被很多人采用,它的特点就是可以直接在浏览器中打开模板文件,方便前端开发。这里选用Thymeleaf模版引擎,它的使用步骤如下:
     (1)添加Thymeleaf引擎依赖:打开pom.xml,添加以下内容。

<dependencies>

      ......

      <dependency>

          <groupId>org.springframework.boot</groupId>

          <artifactId>spring-boot-starter-thymeleaf</artifactId>

      </dependency>

      ......

</


版权声明:本文为pkutao原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。