Freemarker页面抽取只需四步

1、引入freemarker依赖

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

2、application.yml配置,最主要的是最后一个配置。

  freemarker:
    suffix: .ftl
    cache: false
    content-type: text/html
    charset: UTF-8
    template-loader-path: classpath:/templates
    request-context-attribute: request
    settings:
      auto_import: common/common.ftl as common

项目中抽取的common.ftl目录

common.ftl的部分内容:

引用抽取的部分:

发布了18 篇原创文章 · 获赞 18 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/andwey/article/details/105425926