开发者

Getting comma inside value of long type at freemarker page

开发者 https://www.devze.com 2023-01-09 07:21 出处:网络
I am having some strange problem and its really frustating me. I have a list of Car bean in request attribute -

I am having some strange problem and its really frustating me. I have a list of Car bean in request attribute -

List<Car> car开发者_C百科s = 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>


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:

<span>Car Id:</span>${car.id?c}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消