thymeleaf模板迴圈列印1 指定的整數

2021-10-03 09:07:32 字數 394 閱讀 5941

在用thymeleaf末班獲取後台的page物件時,我們需要進行分頁頁碼的顯示,通過page物件的totalpages可以獲取到所有頁面,那麼獲取到的這個整數,怎麼迴圈列印出來呢?

thymeleaf提供了一種函式

#numbers.sequence(inta,intb)
這個函式的作用是迴圈遍歷a-b之間的整數

下面給出例子

="page"th:each=

"i:$"

>

="pageitem" th:text=

"$">

<

/div>

<

/div>

注意我們需要用乙個變數接收所有的整數,再依次列印出來

thymeleaf 模板引擎 的迴圈讀取

1.pom檔案中加入 thymeleaf 的jar org.springframework.boot spring boot starter thymeleaf 在templates下建立乙個html檔案 3.html 如下 注意 xmlns th 這是引入 thymeleaf 的標籤庫 後台傳過來...

thymeleaf模板引擎

thymeleaf 模組引擎類似於jsp的el表示式 1.引入thymeleaf org.springframework.boot spring boot starter thymeleaf 3.0.11.release 2.1.1 2.thymeleaf的使用 語法只要我們把html檔案放在cla...

Thymeleaf模板與Spring MVC整合

thymeleaf 定義了 org.thymeleaf.spring4.view.thymeleafview 和 org.thymeleaf.spring4.view.thymeleafviewresolver 預設使用thymeleafview 作為 view thymeleaf 提供了乙個spr...