SpringBoot整合freemarker展示页面

1、通过maven坐标的方式将freemarker引入到项目中

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>

在application.yml全局配置文件中进行如下的配置

spring:
  freemarker:
    cache: false # 缓存配置 开发阶段应该配置为false 因为经常会改
    suffix: .ftl # 模版文件后缀名 
    charset: UTF-8 # 文件编码
    template-loader-path: classpath:/templates/  

目录结构如下:

2、代码测试

源码地址

参考地址: https://www.kancloud.cn/hanxt/springboot2/1177619

I can feel you forgetting me。。 有一种默契叫做我不理你,你就不理我

原文地址:https://www.cnblogs.com/weidaijie/p/14376008.html