In this article, we will continue to discuss jstl. The i18n tag library is generally used to compile international applications. It is divided into two parts: internationalization, date, time, and number formatting. To use the format tag on the JSP page, you must use the <% @ taglib %> command to specify the format tag. The Code is as follows:
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
International tags
International tags include <FMT: setlocale>, <FMT: bundle>, <FMT: Message>, <FMT: param>, and <FMT: requestencoding>.
<FMT: setlocale> tag
It is used to set the user's local language environment and save the specified locae to the javax. servlet. jsp. jstl. FMT. locale configuration variable. The syntax format is as follows:
<fmt:setLocale value="locale" [variant="variant"] [scope="{page|request|session|application}"] />
Value specifies the language and region code, and Variant specifies the supplier or browser Code. For example, win indicates windows. If the value is null or null, use the default locale.
<FMT: bundle> tag
It is used to create its label bodies using the i18n local context environment. The syntax format is as follows:
<FMT: bundle basename = "basename" [prefix = "prefix"]> body content </FMT: bundle>
Basename indicates the base name of the resource package. prefix specifies the prefix to be added before the Message key of the nested <FMT: Message> tag.
<FMT: setbundle> tag
This label is used to create an i18n local context environment and save it to the javax. servlet. jsp. jstl. localizationcontext configuration variable. The syntax format is as follows:
<fmt:setBundle basename="basename" [var="varName"] [scope="{scope|request|session|application}"] />
VaR indicates the name of the range variable that stores the i18n local context.
<FMT: Message> tag
This tag is used to search for a specified key value from the resource package to display localized messages. There are three syntax formats:
1) syntax format 1, no tag body.
<fmt:message key="messagekey" [bundle="resourceBundle"] [var="varName"] [scope="{page|request|session|application}"] />
2) syntax Format 2, with a tag body, specify message parameters in the TAG body
<fmt:message key="messagekey" [bundle="resourceBundle"] [var="varName"] [scope="{page|request|session|application}"] > <fmt:param> subtags</fmt:message>
3) There is a TAG body. In the TAG body, specify the key and optional message parameters.
<fmt:message [bundle="resourceBundle"] [var="varName"] [scope="{page|request|session|application}"] > key optional<fmt:param> subtags</fmt:message>
Key indicates the key of the message to be searched. Bundle indicates the resource package used. If the key is null ????? Format error message. If no resource package is found ??? <Key> ??? Format error.
<FMT: param> label
This tag provides a parameter for parameter replacement in <FMT: Message>. It has two syntax formats. As follows:
1) syntax format 1: Specify the parameter value through the value attribute.
<fmt:param value="messagevalue" />
2) syntax Format 2: Specify the parameter value through the TAG body
<FMT: param> content </FMT: param>
<FMT: requestencoding>
The tag body is used to set the character encoding of the request. The syntax format is as follows:
<fmt:requestEncoding [value="charsetName"] />
Format tags
<FMT: formatnumber> label
The tag format the number as a number, currency, or percentage based on the region or custom method. The syntax is divided into two types: No ontology content. The value attribute is used to specify the number to be formatted. The ontology content is used to specify the number to be formatted. The syntax format is as follows:
<fmt:formatNumber value="number" [type={number|currency|percent}][pattern="pattern"][currencyCode="currencyCode"][groupingUsed="{true|false}"][maxInterDigits="maxIntegerDigits"][minIntegerDigits="minIntegerDigits"][maxFractionDigits="maxFractionDigits"][minFractionDigits="minFractionDigits"][var="varName"][scope="page|request|session|application"] />
<FMT: parsenumber> label
This label is used to convert numbers, currencies, or percentages of the string type into numeric types. It is opposite to the ID number of the <FMT: formatnumber> label. There are two types of syntax: No ontology content. The value attribute is used to specify the string to be converted to a number. The ontology content is used to specify the string to be converted to a number. The syntax format is as follows:
<fmt:parseNumber value="number" [type={number|currency|percent}][pattern="pattern"][parseLocale="parseLocale"][groupingUsed="{true|false}"][integerOnly="{false|true}"][var="varName"][scope="page|request|session|application"] />
<FMT: formatdate> label
This label will format the date or time according to the region or custom method. The syntax format is as follows:
<fmt:formatDate value="number" [type={time|date|both}][pattern="pattern"][dateStyle="{default|short|medium|long|full}"][timeStyle="{default|short|medium|long|full}"][timeZone="timeZone"][var="varName"][scope="page|request|session|application"] />
<FMT: parsedate> label
This label is used to convert a string-type time or date to a datetime type. This is the opposite of the <FMT: formatdate> label. It can also be divided into two types: Ontology content or Ontology-free content. The syntax format is as follows:
<fmt:parseDate value="number" [type={time|date|both}][pattern="pattern"][dateStyle="{default|short|medium|long|full}"][timeStyle="{default|short|medium|long|full}"][timeZone="timeZone"][var="varName"][scope="page|request|session|application"] />
<FMT: settimezone> tag
This label is used to set the default time zone or store the time zone in the attribute range. The syntax format is as follows:
<fmt:setTimeZone value="timeZone" [var="varName" [scope="{page|request|session|application}"]]/>
<FMT: timezone> tag
This label is used to temporarily set the time zone. The syntax format is as follows.
<FMT: timezone value = "timezone"> body content </FMT: timezone>
Reprinted please indicate the source: http://blog.csdn.net/iAm333