Search code examples
javajspstruts2number-formattingresourcebundle

How to remove comma from a number being dynamically inserted in the value of a key in the properties file / resource bundle?


I am using Struts 2. I have a JSP. It has this code:

<span class="helpMessage">
    <s:text name="page.key">
        <s:param value="%{request.id}" />
    </s:text>
</span>

request object is a member of my action class, and id is a property of the request object. id is of the type int.

In my properties file I have written the following text:

page.key=The request ID is {0} 

My request id is a 6 digit number. Whenever it is displayed on the jsp it is displayed with a comma, eg: 765,239. I want it to be displayed without a comma, like this: 765239. I think the comma is being displayed because the data type of the id is int.

If I convert it to a string by writing the code below then the comma is not displayed.

<s:param value="%{request.id.toString()}" />

I want to know if instead of the above modification in the JSP can I do some modification in the properties file/resource bundle, like inserting a number format, to remove the comma in the number?


Solution

  • i think you are looking for setting the number format.. here is the documentation from Struts 2 regarding this.

    format.number = {0} # i think this should do