freemarker中迭代Map的寫法

2021-09-08 23:56:36 字數 381 閱讀 3330

ftl檔案**如下:

<#assign mymap=stack.findvalue("mymap")/>

<#list mymap?keys as key>

key:$----value:$

stack.findvalue("mymap"),這是struts2裡面的用法,可以查詢頁面中viewstack中的值,mymap是乙個map物件。

mymap[key]?default(""),這裡是判斷值是否為null,如果為null,設定預設值為空,freemarker不支援null,如果值為null,會丟擲異常報錯。

freemarker中迴圈顯示

有乙個list中20個物件,要求每行顯示4個,顯示5行 list名字叫 userlist,其中包含user物件 if userlist?exists list userlist as thisuser if 0 要顯示的內容 其中知識點 1 list標籤 list sequence as item ...

Freemarker中如何遍歷List

freemarker中如何遍歷list 在freemarker應用中經常會遍歷list獲取需要的資料,並對需要的資料進行排序加工後呈現給使用者。那麼在freemarker中如何遍歷list,並對list中資料進行適當的排序呢?一 freemarker中list指令簡單介紹 要想在freemarker...

Freemarker中如何遍歷List

freemarker中list指令簡單介紹 要想在freemarker中遍歷list,必須通過使用list指令,即 list sequence as item sequence是集合 collection 的表示式,item是迴圈變數的名字,不能是表示式。當在遍歷sequence時,會將遍歷變數的值...