formatnumber.jsp
来自「基于netbeans的java桌面应用程序合集」· JSP 代码 · 共 42 行
JSP
42 行
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>JSTL: Formatting/I18N Support -- Number, Currency, and Percent
Example
</title>
</head>
<body bgcolor="#FFFFFF">
<h3>Formatting numbers, currencies, and percentages using <tt>en-US</tt>
locale
</h3>
<fmt:setLocale value="en-US" />
<ul>
<li> Format "123456789" as number:<br>
<fmt:formatNumber value="123456789" />
<li> Format "123456789" as percent:<br>
<fmt:formatNumber type="percent">123456789</fmt:formatNumber>
<li> Format "12345.67" as currency:<br>
<fmt:formatNumber value="12345.67" type="currency" />
<li> Format "12345.67" as currency, with
grouping turned off, the maximum number of digits in the integer portion
limited to 4, and no fraction portion:<br>
<fmt:formatNumber value="12345.67" type="currency"
groupingUsed="false" maxIntegerDigits="4"
maxFractionDigits="0" />
<li> Format "12345.67" as currency:<br>
<fmt:formatNumber value="12345.67" type="currency" /><br>
then parse its integer portion only and output the result:<br>
<fmt:formatNumber value="12345.67" type="currency" var="cur" />
<fmt:parseNumber value="${cur}" type="currency" integerOnly="true" />
</ul>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?