2
我试图输出漂亮的数字从我FreeMarker模板的GeoServer:将散列字符串转换为格式化的数字?
<#list features as feature>
<#if attribute.name="lon" || attribute.name="lat">
<td>${feature[attribute.name].value?round}</td>
<#else>
<td>${feature[attribute.name].value}</td>
</#if>
</#list>
如果我拿出?round
,我得到的东西,如“-121.469166666667”。我只是想把这个数字格式化一点,比如说把它舍入到小数点后4位。
我已经试过几件事情:
${feature[attribute.name].value?number}
${(feature[attribute.name].value)?number.string("0.0000")}
但这些抱怨,所以我感觉像它只是在散输送串到?
的语法问题“预期的哈希值。”正确的操作符,以便我实际上在字符串上执行方法......但是这一直困扰着我。
尝试:$ {((feature [attribute.name] .value * 10000)?round)/ 10000} – stark 2012-03-23 21:20:09