Freemarker的常用語法

2021-10-07 17:47:53 字數 945 閱讀 7902

if判斷語法的使用

<#if name==

'***'

>

hello,$

!<#else

>

你好,$

!<

/#if

>

list集合語法的使用

//遍歷集合

<#list studentlist as student>..

.<

/#list>

//獲取集合的下標(索引值)

$//是否存在下乙個物件,存在返回true,反之返回false

<#if student_has_next>..

.>

map集合語法的使用

//遍歷集合

<#if scores?exists>

<#list scores?keys as key>

key:$

;value:$

<

/#list>

<

/#if

>

空值處理運算子

freemarker對空值的處理非常嚴格,freemarker的變數必須有值,沒有被賦值的變數就會丟擲異常。

!:指定缺失變數的預設值;

??:判斷某個變數是否存在。

用法:$:沒有給定預設值,預設為空字串,長度為零的集合。

$:給定乙個預設值,不要求預設值的型別,可相同也可不同。

//該變數存在返回true,否則返回false

<#if variable?

?>..

.<

/#if

>

freemarker常用語法

常用語法 三 eg.乙個物件book 1.輸出 空值判斷 預設值 預設值 日期格式 數字格式 20 插入布林值 邏輯判斷 2 a inc 發布於2007 09 08 16 18 57 ion2 其中空值判斷可以寫成 b 迴圈讀取 3 空值判斷 e.g.用來壓縮空白空間和空白的行 用例 1 2 3 4...

mysql常用語法 MySQL常用語法

更新資料 update 表名 set 健名 更改的值 where 建 刪除資料 delete from 表名 where 索引 create index 索引名稱 on 表名 鍵名 建立試圖 create view 檢視名 鍵,鍵 as select matchno,abs won lost fro...

mysql基本常用語法 mysql 常用語法

1.1.開啟 service mysql start 1.2.關閉 service mysql stop 1.3.重啟 service mysql restart 2.1.密碼明文 語法 mysql u使用者名稱 p使用者密碼 舉例 mysql uroot p123456 2.2.密碼密文 語法 m...