Java – how do I format numbers in the expression language?

How do I format and output numbers (such as long or BigDecimal) in El? For example, I want to limit some decimal numbers to 3

${result.returnValue.contract.balance}

Solution

Use < FMT: formatnumber / >

http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/formatNumber.html

For example:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<fmt:formatNumber 
     value="${result.returnValue.contract.balance}" 
     maxFractionDigits="3"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>