V. FMT tag Library
This tag library is used for international operations, such as time format, digital format conversion, and Region conversion;
1. supplement international knowledge
Zh_cn China
En_us us
Fr_fr France
2. <FMT: setlocale>
Used to determine the region. The general structure is as follows:
<FMT: setlocale value = ""/>
Value indicates the specified region, such as zh_cn;
3. <FMT: requestencoding>
Used to set the encoding. The general structure is as follows:
<FMT: requestencoding value = ""/>
Value is used to specify the encoding, such as GBK;
4. <FMT: setbundle> and <FMT: Message> are used to operate resource files.
Note: The resource file is placed under the WEB-INF/classes!
Set the resource file. The general structure is as follows:
<FMT: setbundle basename = "" Var = ""/>
Basename indicates the name of the resource file. The suffix of properties is not required. var indicates the attribute name of the resource file;
VaR is used in the <FMT: Message bundle = ""> attribute.
For example:
<FMT: setbundle basename = "1" Var = "PM"/>
<FMT: Message bundle ="$ {Pm}"/>
5. <FMT: Message>
Obtain the value corresponding to a specific key in the resource file. The general structure is as follows:
<FMT: Message key = "" Var = "" bundle = "/>
Key is used to specify a key;
VaR stores the value of value;
Bundle indicates the resource file;
6. <FMT: formatnumber>
Used to format numbers. The general structure is as follows:
<FMT: formarnumber value = "" Var = "" maxintegerdigits = "" maxfractiondigits = "" groupingused = ""/>
Value indicates the value to be formatted;
VaR stores the formatted value;
Maxintegerdigits is used to specify the number of digits in the integer part;
Maxfractiondigits is used to specify the digits of the fractional part;
Groupingused is used to specify whether a "," is separated; true or false
7. <FMT: parsenumber>
Parse numbers. The general structure is as follows:
<FMT: parsenumber value = "" Var = ""/>
8. <FMT: formatdate>
Format the date. The general structure is as follows:
<FMT: formatdate value = "" type = "" pattern = "" Var = ""/>
Type indicates formatting date or time, or all formatting, date, both, and time;
Pattern indicates the formatted format;
VaR: Save the result;
9. <FMT: parsedate>
Resolution date. The general structure is as follows:
<FMT: parsedate value = "" pattern = "" Var = ""/>
Code example:
<%@ page contentType="text/html" pageEncoding="GBK" import="java.util.*"%><%@ taglib prefix="fmt" uri="jstl/fmt"%><jsp:useBean id="per" class="org.person.Person" scope="page"/>
Vi. FN tag Library
The label of this tag library is similar to the method provided by string;
1. $ {fn: Contains (STR, "Var")} whether the string has VaR
2. $ {fn: containsignorecase (STR, "Var ")}
Whether the string has VAR (Case Insensitive)
3. $ {fn: startswith (STR, "Var")} whether the string starts with VAR
4. $ {fn: endswith (STR, "Var")} whether the string ends with VAR
5. $ {fn: substring (STR, int begin, int end )};
Extract string from begin-end-1
6. $ {fn: trim (STR)} remove the Left and Right Spaces
7. $ {fn: touppercase (STR)} Are all capitalized.
8. $ {fn: Replace (STR, "var1", "var2 ")};
Replace var1 with var2
9. $ {fn: Split (STR, ",") [I]} is divided by "," and 2nd are retrieved;