SpringBoot FreeWorker模板技术解析

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

SpringBoot FreeWorker模板技术解析

  2021-04-02 我要评论

这篇文章主要介绍了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中的测试代码

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们