Friday, June 19, 2009

JSTL formatNumber as percentage gets invalid attribute error

fmt:formatNumber <formatNumber> invalid type attribute: "percentage" percent

The JSTL Tag Library documentation seems to indicate that to format a number as a percentage you'd use:

<fmt:formatNumber type="percentage" value="0.5"/>

This gives the error message
<formatNumber>, invalid type attribute: "percentage"

Although the documentation for type says "Specifies whether the value is to be formatted as number, currency, or percentage" these aren't the possible values - it's "percent" for percentage:

<fmt:formatNumber type="percent" value="0.5"/>

If you know a good reference for JSTL I'd like to know ...

The Appendix A from JSTL in Action is not bad - it documents possible values for formatNumber type at least.

No comments: