Jsp-el-expression

Source: Internet
Author: User

---El expression retains two decimal places, retains two decimal places using JSTL <fmt:formatNumber> tags

<%@ taglib uri= "http://java.sun.com/jsp/jstl/fmt" prefix= "FMT"%>
<fmt:formatnumber type= "number" value= "${688.87 * 0.8}" pattern= "0.00" maxfractiondigits= "2"/>

< TD ><  type= "number"  value= "${item.lakecoin}"  pattern= "0.00"  /></td>

<fmt:formatnumber type= "number" value= "${LB.MONBZFJ}" maxfractiondigits= "2"/> What does maxfractiondigits= "2" mean here?

Max fraction decimal digits number of digits
Maximum number of decimal digits = 2

---JSP page shows red when a variable is negative
<TDNoWrap class= "TDJJ"Align= "Center">    <c:ifTest= "${list.profitmoney < ' 0 '}">        <FontColor= "Red">${list.profitmoney}</Font>    </c:if>    <c:ifTest= "${list.profitmoney >= ' 0 '}">        <FontColor= "BLACK">${list.profitmoney}</Font>    </c:if></TD>

${list.profitmoney} is the value of a variable that is queried by a JSP page.

The above code is to implement if negative, the font color is marked red. If positive or 0, the font color is black.

<TDMethods of >//if  <c:ifTest= "${item.anxcoin<0}">        <FontColor= "Red"><Fmt:formatnumbertype= "Number"value= "${item.anxcoin}"pattern= "0.00" /></Font>  </c:if>  <c:ifTest= "${item.anxcoin>=0}">        <Fmt:formatnumbertype= "Number"value= "${item.anxcoin}"pattern= "0.00" />  </c:if></TD>

Method of Choose when otherwise

<TD><C:choose>    <C:whenTest= "${item.anxcoin<0}">        <FontColor= "Red"><Fmt:formatnumbertype= "Number"value= "${item.anxcoin}"pattern= "0.00" /></Font>    </C:when>    <c:otherwise><Fmt:formatnumbertype= "Number"value= "${item.anxcoin}"pattern= "0.00" /></c:otherwise></C:choose></TD>

Jsp-el-expression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.