SpringBoot FreeWorker模板技術解析
阿新 • • 發佈:2020-01-07
這篇文章主要介紹了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中的測試程式碼
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援我們。