zoukankan      html  css  js  c++  java
  • SpringBoot整合模版引擎freemarker实战

    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 

    测试

  • 相关阅读:
    csp2020游记
    agc006_f Blackout
    CF1368G Shifting Dominoes
    AtCoder Grand Contest 009 简要题解
    Codeforces Round #666 (Div. 1)
    CSP 2019 树的重心
    Luogu-P4859 已经没什么好害怕的了
    2020.9.17 校内测试
    CF379F New Year Tree
    图论(小结论)
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/13251989.html
Copyright © 2011-2022 走看看