一、 Sequence的内置函数
1. sequence?first 返回sequence的第一个值。
2. sequence?last 返回sequence的最后一个值。
3. sequence?reverse 将sequence的现有顺序反转,即倒序排序
4. sequence?size 返回sequence的大小
5. sequence?sort 将sequence中的对象转化为字符串后顺序排序
6. sequence?sort_by(value) 按sequence中对象的属性value进行排序
二、 Hash的内置函数
1. hash?keys 返回hash里的所有key,返回结果为sequence
2. hash?values 返回hash里的所有value,返回结果为sequence
例如:
<#assign user={“name”:“hailang”, “sex”:“man”} />
<#assign keys=user?keys />
<#list keys as key>
${key}=${user[key]}
</#list>
三、 操作字符串函数
1. substring(start,end)从一个字符串中截取子串
start:截取子串开始的索引,start必须大于等于0,小于等于end
end: 截取子串的长度,end必须大于等于0,小于等于字符串长度,如果省略该参数,默认为字符串长度。
例子:
${‘str’?substring(0)},结果为str
${‘str’?substring(1)},结果为tr
${‘str’?substring(2)},结果为r
${‘str’?substring(3)},结果为
${‘str’?substring(0,0)},结果为
${‘str’?substring(0,1)},结果为s
${‘str’?substring(0,2)},结果为st
${‘str’?substring(0,3)},结果为str
2.cap_first 将字符串中的第一个单词的首字母变为大写。
${‘str’?cap_first},结果为Str
3. uncap_first将字符串中的第一个单词的首字母变为小写。
${‘Str’?cap_first},结果为str
4. capitalize将字符串中的所有单词的首字母变为大写
${‘str’?capitalize},结果为STR
5. date,time,datetime将字符串转换为日期
例如:
<#assign date1=”2009-10-12”?date(“yyyy-MM-dd”)>
<#assign date2=”9:28:20”?time(“HH:mm:ss”)>
<#assign date3=” 2009-10-12 9:28:20”?time(“HH:mm:ss”)>
${date1},结果为2009-10-12
${date2},结果为9:28:20
${date3},结果为2009-10-12 9:28:20
注意:如果指定的字符串格式不正确将引发错误。

<转>FreeMarker内置函数的更多相关文章

  1. Freemarker 内置函数 数字、字符串、日期格式化用法介绍

    在用FreeMarker过程中,感觉FreeMarker的字符串,日期,集合等处理能力还是很强大的,上网搜了一些资料,整理如下,以便能帮助大家更熟练的应用Freemarker完成项目开发. 一.Seq ...

  2. freemarker内置函数和用法

    原文链接:http://www.iteye.com/topic/908500 在我们应用Freemarker 过程中,经常会操作例如字符串,数字,集合等,却不清楚Freemrker 有没有类似于Jav ...

  3. Freemarker中遍历List以及内置函数使用

    在Freemarker应用中经常会遍历List获取需要的数据,并对需要的数据进行排序加工后呈现给用户. 那么在Freemarker中如何遍历List,并对List中数据进行适当的排序呢?一. Free ...

  4. FreeMarker惯用内置函数

    1.sequence?first 返回sequence的第一个值. 2.sequence?last 返回sequence的最后一个值. 3.sequence?reverse 将sequence的现有顺 ...

  5. Entity Framework 6 Recipes 2nd Edition(11-12)译 -> 定义内置函数

    11-12. 定义内置函数 问题 想要定义一个在eSQL 和LINQ 查询里使用的内置函数. 解决方案 我们要在数据库中使用IsNull 函数,但是EF没有为eSQL 或LINQ发布这个函数. 假设我 ...

  6. Oracle内置函数:时间函数,转换函数,字符串函数,数值函数,替换函数

    dual单行单列的隐藏表,看不见 但是可以用,经常用来调内置函数.不用新建表 时间函数 sysdate 系统当前时间 add_months 作用:对日期的月份进行加减 写法:add_months(日期 ...

  7. python内置函数

    python内置函数 官方文档:点击 在这里我只列举一些常见的内置函数用法 1.abs()[求数字的绝对值] >>> abs(-13) 13 2.all() 判断所有集合元素都为真的 ...

  8. DAY5 python内置函数+验证码实例

    内置函数 用验证码作为实例 字符串和字节的转换 字符串到字节 字节到字符串

  9. python之常用内置函数

    python内置函数,可以通过python的帮助文档 Build-in Functions,在终端交互下可以通过命令查看 >>> dir("__builtins__&quo ...

随机推荐

  1. n全排列输出和 n个数的组合(数字范围a~b)

    n全排列输出: int WPermutation(int num, bool bRepeat) num表示num全排列 bRepeat标志是否产生重复元素的序列. int Permutation(in ...

  2. ubuntu安装skype

    1.添加源 sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner&quo ...

  3. NFV技术中遇到的新名词

    NUMA topology:Non-Uniform Memory Access (NUMA) is a computer system architecture that is used with m ...

  4. 【Other】最近正在看的

    待看: https://my.oschina.net/yunfound/blog/141222 https://www.zhihu.com/question/22925358 http://study ...

  5. Oracle 数据操作

    查询及删除重复记录的SQL语句   1.查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断   select * from 表 where Id in (select Id from 表 g ...

  6. 【leetcode】Anagrams

    Anagrams Given an array of strings, return all groups of strings that are anagrams. Note: All inputs ...

  7. Twisted安装

    Debian sudo apt-get install gcc python-dev && sudo pip install twisted CentOS sudo yum insta ...

  8. 如何在maven中添加本地jar包

    mvn install:install-file -DgroupId=mytest-DartifactId=test-Dversion=1.1 -Dpackaging=jar -Dfile=d:\te ...

  9. default constructor,copy constructor,copy assignment

     C++ Code  12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...

  10. 4.js模式-发布-订阅模式

    1. 发布-订阅模式 var observe = (function(){ var events = {}, listen, trigger, remmove; listen = function(k ...