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.启动项目如图

本文详细介绍如何在Spring Boot项目中引入FreeMarker模板引擎,包括添加pom依赖、配置yml文件、设置模板加载路径及编码格式等步骤,并提供测试接口和页面文件的具体配置示例。

514

被折叠的 条评论
为什么被折叠?



