Freemarker中的常用函数


  • 数字转字符串
    ${1234?c}
    
  • 截取字符串
    ${"abcd"?substring(1,3)} <!--从第2个字符开始截取到第3个字符结束-->
    
  • 计算字符串长度
    ${"abcd"?length}
    
  • 字符串转数字
    ${"0123"?number}
    
  • 字符串按分隔符号转数组
    <#assign arr=("a,b,c,d"?split(","))>
    <#list arr as item>
    ${item}
    </#list>
    
  • 日期转字符串
    ${.now?string("yyyy-MM-dd HH:mm:ss")}
  • 日期转整型
    #{.now?long}
    
  • 字符串替换
    ${url?replace("www.zhso.net","zhso.net")}
    

评论
changfg
收藏了
Jaylynn
A provocative ingsiht! Just what we need!
Bette
Your crniaum must be protecting some very valuable brains.
Deandra
I rcekon you are quite dead on with that.
Catherine
强大!
Nicole
博主很强大,我支持