tags:

views:

2232

answers:

1

I would like to format number displayed by <s:property value="summary.total"/> tag in Struts 2. There is a double value. How can I do that? Should I use OGNL?

Or maybe I must use <s:text/> tag and define my format in resuource file?

A: 

You need to use <s:text/> with <s:param/>.

Property file: summary.cost= € {0,number,##0.00}

JSP:

<s:text name="summary.cost" > <s:param name="value" value="summary.total"/> </s:text>

If I understood right what you mean...

Trick
Yeah, I found that, but I thought that maybe there is something quicker :)
prostynick
A `double` value, and €? I surely hope that you don't use floating point numbers for currency.
Svante
I never mentioned € and Trick never mentioned `double` ;)
prostynick
Quicker is only with <s:date/> tag, which has format attribute. You can, of course, implement your own tag, which could have formatting included :)
Trick