zoukankan      html  css  js  c++  java
  • springboot整合freemarker

    springboot “天生”支持freemarker模板,创建好springboot项目后,resources下面会又一个templates文件夹,默认使用该文件夹下的模板,下面来看一下简单的引入配置。

    #设置freemarker模板后缀
    spring.freemarker.suffix=.html
    #修改模板默认文件夹
    #spring.freemarker.template-loader-path=classpath:/web

    freemarker默认的模板后缀为 .ftl  为了方便在eclipse内编辑,现改为 .html

    可通过spring.freemarker.template-loader-path=classpath:/web 修改系统默认的 模板存放路径

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <h3>hello,freemarker</h3>
    <h4>${str}</h4>
    </body>
    </html>
    package com.example.demo.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @Controller
    @RequestMapping("/student/")
    public class StudentController {
        
        @RequestMapping("show")
        public String show(Model model) {
            model.addAttribute("str", "this is spring boot freemarker");
            return "show";
        }
    
    }
  • 相关阅读:
    本周开发工作时间及内容
    自我介绍
    代码规范
    结对编程
    第二周总结
    20140227WPF学习笔记
    约瑟夫问题
    模式匹配KMP算法
    .NET开发之窗体间的传值转化操作
    北达软TOGAF9鉴定级别认证考试通知 北达软
  • 原文地址:https://www.cnblogs.com/blog411032/p/10339141.html
Copyright © 2011-2022 走看看