在 freemarker 页面获取 long 类型值内的逗号
我遇到了一些奇怪的问题,这真的让我很沮丧。我在请求属性中有一个 Car bean 列表 -
List<Car> cars = myservice.getCars();
request.setAttribute("cars", cars);
当我打印汽车 ID(长类型)时,它给了我正确的值 -
for(Car car: cars) {
System.out.println(car.id);
}
// It gives me - 11231, 11245, 11253
-
11,231
11,245
11,253
但是当我试图在 freemarker 页面 resutl.ftl 上获得相同的值时,它给我的值为 代码是-
<#list cars as car>
<span>Car Id:</span>${car.id}
<#list>
I am having some strange problem and its really frustating me. I have a list of Car bean in request attribute -
List<Car> cars = myservice.getCars();
request.setAttribute("cars", cars);
When I print the car ids (long type), it gives me correct value -
for(Car car: cars) {
System.out.println(car.id);
}
// It gives me - 11231, 11245, 11253
But when I am trying to get same on freemarker page resutl.ftl, its giving me values as -
11,231
11,245
11,253
The code is -
<#list cars as car>
<span>Car Id:</span>${car.id}
<#list>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数字格式似乎与区域设置相关。此常见问题解答条目似乎提供了修复:
http://freemarker.sourceforge.net/docs/ app_faq.html#faq_number_grouping
从该页面(仅该页面,在您提出问题之前我从未听说过 Freemarker),似乎这可能会满足您的要求:
或者您可以调整您的区域设置或数字格式变得更像你所期望的那样。上面的链接详细介绍了具体操作方法。
Formatting of numbers appears to be locale-sensitive. This FAQ entry appears to give a fix:
http://freemarker.sourceforge.net/docs/app_faq.html#faq_number_grouping
From that page (and that page alone, I'd never heard of Freemarker before your question), it seems that this might do what you want:
Or you could adjust your locale settings or number format to be something more like you expect. Exactly how to do that is detailed in the link above.