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

夙愿已清 提交于 2020-08-14 09:26:59

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>

      ......

</dependencies>

如图3-6所示。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!