A detailed explanation of FMT tags in various formats of-JSTL

Source: Internet
Author: User
Tags i18n

One: The JSTL format label, also known as the i18n tag library, is used primarily to write internationalized Web applications that can be appropriately processed for a specific language request.

For example: Chinese mainland users will display Simplified Chinese, Taiwan is the traditional Chinese, the use of i18n format Tag library can also format numbers and dates, such as the same number or increasingly, in different countries may have different formats, using the I18N format tag library can format numbers and dates in the local format.

Two: Format label

<fmt:fromatNumber>

<fmt:formatDate>

<fmt:parseDate>

<fmt:parseNumber>

<fmt:setTimeZone>

<fmt:timeZone>

Internationalization label

<fmt:setLocale>

<fmt:requestEncoding>

<fmt:bundle>

<fmt:message>

<fmt:param>

<fmt:setBundle>

To use a format tag in a JSP page, you need to introduce the following statement:

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

Three:<fmt:formatnumber>

This label formats the number as a number, currency, or percentage, based on the locale customization.

Properties of this label:

Value: the number to format

Type: Format by what

Pattern: Customizing formatting styles

currencycode:iso-4721 currency codes, applicable only to numbers formatted with currency

CurrencySymbol: Currency symbols, such as ¥, that apply only to numbers formatted with currency
Groupingused: whether to include delimiters
Maxintegerdigits: The maximum number of digits displayed in the integer section
Mixintegerdigits: The minimum number of bits shown in the integer section
Maxfractiondigits: The fractional portion displays up to multiple digits
Minfractiondigits: The decimal portion displays at least multiple digits
var: storage-formatted results
Scope: The range of storage

Example 1:

Java code
<%@ page language= "java" pageencoding= "Utf-8"%>
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
<%@ taglib uri= "http://java.sun.com/jsp/jstl/fmt" prefix= "FMT"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>chapter4.jsp</title>
<body>
<div>
<div>
<fmt:setlocale value= "Fr_fr"/>
<fmt:formatnumber value= "123456789.012"/>
<br/>
<fmt:setlocale value= "Zh_cn"/>
<fmt:formatnumber value= "123456789.012"/>
<br/>
<fmt:setlocale value= "De_de"/>
<fmt:formatnumber value= "123456789.012"/>
<br/>
</div>
</div>
</body>

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.