首页 > 编程语言 > 详细

SpringBoot整合模版引擎freemarker实战

时间:2020-07-05 21:49:58      阅读:46      评论:0      收藏:0      [点我收藏+]

Freemarker相关maven依赖

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

Freemarker基础配置

application.properties

spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/
# 是否开启thymeleaf缓存,本地为false,生产建议为true
spring.freemarker.cache=false
spring.freemarker.charset=utf-8
spring.freemarker.allow-request-override=false
spring.freemarker.check-template-location=true
# 类型
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
# 文件后缀
spring.freemarker.suffix=.ftl
# 路径
spring.freemarker.template-loader-path=classpath:/templates/

建立文件夹

1)src/main/resources/templates/user/fm/
2)建立一个index.ftl

index.ftl

技术分享图片

 

FreemarkerController.java 

技术分享图片

 

测试

技术分享图片

 

SpringBoot整合模版引擎freemarker实战

原文:https://www.cnblogs.com/chenyanbin/p/13251989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!