Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent default formatting (comma insertion) of long argument in s:message tag

I have a jsp in which I use spring s:message tag

<s:message code="application.success" arguments="${applicationRefId}" />

applicationRefId is a long variable added to the model.

In my resource bundle, I have defined message code quite regularly as

application.success=Application {0} successfully submitted

But this results in

Application 74,311 successfully submitted

Here my long value is formatted with commas. I have two questions - Why does this formatting happen, by default, and how can I prevent it?

like image 765
Sumit Jain Avatar asked Sep 04 '13 07:09

Sumit Jain


1 Answers

As far as I know you can either

  1. convert applicationRefId to String before passing it to messageTag

  2. or apply formatting in your resource bundle

     application.success=Application {0, number, #} successfully submitted
    

Second solution documentation

  • MessageFormat
  • DecimalFormat

From the MessageFormat documentation

FormatElement:
     { ArgumentIndex }
     { ArgumentIndex , FormatType }
     { ArgumentIndex , FormatType , FormatStyle }

And this chart enter image description here

like image 53
ikumen Avatar answered Oct 13 '22 00:10

ikumen