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";
        }
    
    }
  • 相关阅读:
    Storyboard里面的几种Segue区别和视图的切换
    2014年12月英语单词
    测试和调试的区别
    黑苹果安装教程(一)
    IOS基础——IOS学习路线图(一)
    遇到Wampserver遇到的问题
    产生不重复的数字
    简单的布局
    2014年8月
    算法小全
  • 原文地址:https://www.cnblogs.com/blog411032/p/10339141.html
Copyright © 2011-2022 走看看