Spring boot + Freemarker 整合

1.首先要添加freemarker依赖包

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

2.在appliaction.yml加入freemarker配置文件

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.##' #数字格式化,无小数点

如果只是用mvc 则只要在appliaction.yml配置,默认访问templates路径下文件
mvc:
view:
prefix:
suffix: .htm
posted @ 2018-04-20 17:07  你的名称已被使用  阅读(234)  评论(0编辑  收藏  举报