1.引入pom依赖
org.springframework.boot spring-boot-starter-freemarker2.向yml格式配置文件添加内容
spring:
freemarker:
request-context-attribute: req #req访问request
suffix: .html #后缀名
content-type: text/html enabled: true
cache: false #缓存配置
template-loader-path: classpath:/templates/ #模板加载路径 按需配置 charset: UTF-8 #编码格式
settings:
number_format: '0.##' #数字格式化,无小数点
3.测试接口如图
4.index文件位置如图
index 内容
5.启动项目如图