* 在模板中直接加.toString()转化数字为字符串,如 ${num.toString()}
* 使用?c控制,如 ${num?c}
* 在freemarker配置文件freemarker.properties(在class目录下即可)加number_format=#
* 在模板中直接加<#setting number_format="#">;
* 使用?c控制,如 ${num?c}
* 在freemarker配置文件freemarker.properties(在class目录下即可)加number_format=#
* 在模板中直接加<#setting number_format="#">;
* 通过freemarker.template.Configuration的config.setNumberFormat("#")来设定freemarker对数值的格式化;
原文地址:
http://rongjih.blog.163.com/blog/static/3357446120127262852359/
Freemarker模板引擎中数字转字符串的多种方法

本文详细介绍了在Freemarker模板引擎中将数字转换为字符串的几种方式,包括直接使用toString()方法、使用?c控制、在配置文件中设置number_format、在模板中设置<#settingnumber_format>以及通过Configuration类设置格式化的具体步骤。
1225

被折叠的 条评论
为什么被折叠?



