SpringBoot FreeWorker模板技術解析
這篇文章主要介紹了SpringBoot FreeWorker模板技術解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
一、添加依賴
<!--模板依賴-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
二、在resources/templates 目錄下創(chuàng)建 后綴名為 .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中的測試代碼

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
基于Spring Cloud Zookeeper實現(xiàn)服務注冊與發(fā)現(xiàn)
這篇文章主要介紹了基于Spring Cloud Zookeeper實現(xiàn)服務注冊與發(fā)現(xiàn),幫助大家更好的理解和學習spring框架,感興趣的朋友可以了解下2020-11-11
spring boot基于DRUID實現(xiàn)數(shù)據(jù)源監(jiān)控過程解析
這篇文章主要介紹了spring boot基于DRUID實現(xiàn)數(shù)據(jù)源監(jiān)控過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2019-12-12
java springboot poi 從controller 接收不同類型excel 文件處理
這篇文章主要介紹了java springboot poi 從controller 接收不同類型excel 文件處理,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10

