freemarker常用值格式化方法

  freemarker常用的值格式化方法:

1、${price?string('0.00')}

对price进行格式化,小数点后不足2位用0补足。

比如:price=1

输出:1.00

2、${price?string('#.##')}

对price进行格式化,小数点后多余2位只保留2位,少于2位显示实际位数。

比如:price=1.234

输出:1.23

3、${price?string.currency}

对price进行格式化,显示为货币格式。

比如:price=1

输出:¥1.00

4、${price?string.percent}

对price进行格式化,显示为百分比。

比如:price=1

输出:100%

原文地址:https://www.cnblogs.com/pcheng/p/5566773.html