LoginSignup
8
8

More than 5 years have passed since last update.

FreeMarkerの記法

Last updated at Posted at 2013-04-06

Gist投稿テストも兼ねた

小数の記法

#{hoge ;format}
formatはm1,M1とかある
http://freemarker.sourceforge.net/docs/ref_depr_numerical_interpolation.html

booleanの変数を表示する

hoge?string で表示する

リストがあるか?

list?has_content

Mapでデータを取得するとき

keyがstringの場合
<#list map?keys as key>
${map[key]} <#-- mapの中身が取れる -->
</#list>

keyがint,double等の場合
<#list map?keys as key>
${map.get(key?int)} <#-- doubleの場合は key?double -->
</#list>

これでも
<#list map.entrySet() as entry>
${entry.key} = ${entry.value}
</#list>

??と?has_contentの違い

「??」は変数が存在すればtrueを返し、「?has_content」は変数が存在してかつ中身が空でないときにtrueを返してくれるみたいです。

bean.isIosServiceとかの場合

<#if bean.isIosService> </#if> では評価時にエラーをおこすことがある <#if bean.isIosService()> </#if>とJavaのままで書く
プロパティ名によっては<#if bean.xxx> でいける。(例: <#if bean.open>とか)

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8