curious1
curious1

Reputation: 14717

Spring MVC: how to prevent Spring from adding commas in numbers for generated strings

On my JSP page, I have the following:

<spring:message code="label.generate.codes" arguments="${requestScope.numberOfCodes}"/>

In my properties file, I have the following message:

label.generate.codes=generate {0} codes.

If the numberOfCodes is 1000 or more, here is the final generated string in html:

generate 1,000 codes.

How can I prevent Spring from adding commas in a number? Put it another way, I want to have the following:

generate 1000 codes.

Thanks!

Upvotes: 1

Views: 514

Answers (2)

Amit Parashar
Amit Parashar

Reputation: 1457

I do not think spring message tag adds the comma, you mentioned. It may have been introduced due to toString() implementation of your numberOfCodes object.

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691795

You could use

label.generate.codes=generate {0,number,#} codes.

Or you could pass a String instead of a number as argument to the tag.

Upvotes: 1

Related Questions