首页 > 编程语言 > 详细

SpringBoot 模板技术 之 FreeWorker

时间:2019-11-06 00:48:08      阅读:135      评论:0      收藏:0      [点我收藏+]

 

一、添加依赖

 <!--模板依赖-->
        <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中的测试代码

技术分享图片

 

 

 

 

 

 

 

 

 

SpringBoot 模板技术 之 FreeWorker

原文:https://www.cnblogs.com/lqcswy/p/11802647.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!