您的位置:首页 > 编程语言 > Java开发

springboot配置freemarker使用application.properties

2019-01-19 16:38 489 查看

一、Maven添加引入`

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

二、在application.properties文件中配置freemarker

spring.freemarker.template-loader-path=classpath:/templates/
spring.freemarker.charset=utf-8
spring.freemarker.cache=false
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.expose-spring-macro-helpers=true
spring.freemarker.suffix=.ftl

三、目录结构

四、控制器使用@Conntroller注解

五、页面部分

六、配置完成 运行

附:application.yml

spring:
freemarker:
allow-request-override: false
cache: false
check-template-location: true
charset: utf-8
content-type: text/html
expose-request-attributes: true
expose-session-attributes: true
expose-spring-macro-helpers: true
suffix: .ftl
template-loader-path: classpath:/templates/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐