Spring boot + Freemarker 整合
阿新 • • 發佈:2018-04-20
ext temp har 默認 htm star HA artifact AR
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
Spring boot + Freemarker 整合