SpringBoot2.x系列教程(三十三)Thymeleaf手动渲染实例讲解

在前面章节中我们讲解了Thymeleaf作为前端页面展示时的基本使用。之前我们也提到,Thymeleaf除了可以用于Web前端,也可以用于基于模板其他场景。

比如在发送邮件时,想让邮件的内容和格式更统一些、根据模板生成一些静态的页面或文本等,都可以使用Thymeleaf。

下面我们以Thymeleaf模板来生成邮件内容为例进行讲解,该实例依旧基于SpringBoot来进行实现。

项目引入依赖如下:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <s

猜你喜欢

转载自blog.csdn.net/wo541075754/article/details/103984098