zoukankan      html  css  js  c++  java
  • SpringBoot 模板技术 之 FreeWorker

     

    一、添加依赖

     <!--模板依赖-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-freemarker</artifactId>
            </dependency>

    二、在resources/templates 目录下创建 后缀名为 .ftl 的文件

    ftl文件中的语法:基础模板和html一样

    <html>
        <head>
            <title>car</title>
        </head>
        <body>
            <table align="center" border="1px" cellspacing="0px" cellpadding="10px">
                <thead>
                    <tr>
                        <th>品牌</th>
                        <th>价格</th>
                    </tr>
                </thead>
                <tbody>
                    <#list carList as car>
                        <tr>
                            <td>${car.brand}</td>
                            <td>${car.price}</td>
                        </tr>
                    </#list>
                </tbody>
            </table>
        </body>
    </html>

    ftl中的遍历:

     三、Controller中的测试代码

  • 相关阅读:
    grid 布局
    数组对象
    定义换页时表现
    判断一个对象是否为空
    内存管理 内存泄漏
    arguments对象
    String类型
    对象 实例
    iOS 之 UIWebView
    iOS 之 内嵌网页
  • 原文地址:https://www.cnblogs.com/lqcswy/p/11802647.html
Copyright © 2011-2022 走看看