Search code examples
jspjstllocale

Adding A Euro Symbol to Amount field in JSTL


I have the following code which displays an amount field. I'd like to add the Euro Symbol before the amount field gets displayed. Is this possible to do without changing the formatting?

<div>
    <span class="Amount"></span>
     <fmt:formatNumber type="number" minFractionDigits="2" maxFractionDigits="2" value="${pay.Amount}" var="fmtAmount"/>
     <c:out value="${fmtAmount}"/>
</div>

Solution

  • Currency characters are part of the Unicode character set, so you need to declare that in the head of your documents:

    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    

    Add the below format in your value. So you can show your money value as euro.

    friendlycode : &euro;   
    Numerical Code : &#128;     
    Hex Code : &#x80; 
    

    Hope this helps.