Jstl Usage Summary (2) FMT Tag library and FN Tag library

Source: Internet
Author: User

Five, FMT tag library


The function of this tag library is to perform internationalized operation, such as time format, conversion of digital format, region conversion, etc.


1. International Knowledge Supplement

ZH_CN China

en_US USA

FR_FR France


2.<fmt:setlocale>

For the determination of the region, the general structure is as follows:

<fmt:setlocale value= ""/>

Value represents the specified region, such as ZH_CN;


3.<fmt:requestencoding>

Used to set the code, the general structure is as follows:

<fmt:requestencoding value= ""/>

Value is used to specify the encoding, such as GBK;


4.<fmt:setbundle> <fmt:setBundle> <fmt:message> are used to manipulate resource files. Note: The resource file is placed under Web-inf/classes.

Setting up resource files; The general structure is as follows:

<fmt:setbundle basename= "" var= ""/>

BaseName indicates the name of the resource file, does not require a properties suffix, and var represents the attribute name of the resource file;

var is used in the <fmt:message bundle= "" > Properties.

Like what:

<fmt:setbundle basename= "1" var= "PM"/>

<fmt:message bundle= "${pm}"/>


5.<fmt:message>

Gets the value of a particular key in the resource file; The general structure is as follows:

<fmt:message key= "var=" "bundle=" "/>

Key is used to specify keys;

var saves value;

Bundle represents a resource file;


6.<fmt:formatnumber>

Used to format numbers; The general structure is as follows:

<fmt:formarnumber value= "var=" "maxintegerdigits=" "maxfractiondigits=" "GroupI" Ngused= ""/>

Value represents the values that need to be formatted;

var saves the formatted value;

Maxintegerdigits is used to specify the number of digits in the integer part;

Maxfractiondigits is used to specify the number of digits of a decimal part;

Groupingused is used to specify whether every 3-bit one "," is split; True or False


7.<fmt:parsenumber>

The general structure of the figure is as follows:

<fmt:parsenumber value= "" var= ""/>


8.<fmt:formatdate>

Format Date; The general structure is as follows:

<fmt:formatdate value = "type=" "pattern=" "var=" "/>

Type represents the formatted date or time, or all formatting, date, both, times;

Pattern represents a formatted format;

var save result;


9.<fmt:parsedate>

The resolution date is as follows:

<fmt:parsedate value= "pattern=" "var=" "/>


Code instance:


<%@ 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 "/>  



six, fn tag library

The label for this tag library is similar to the method provided by string;


1.${fn:contains (str, "Var")} string exists var

2.${fn:containsignorecase (str, "Var")} string exists var (ignores case)

3.${fn:startswith (str, "Var")} string starts with Var

4.${fn:endswith (str, "Var")} string ends with Var

5.${fn:substring (str,int begin,int end)}; Intercept string from Begin-end-1

6.${fn:trim (str)} remove left and right spaces

7.${fn:touppercase (str)} all uppercase

8.${fn:replace (str, "var1", "Var2")}; Replace Var1 as Var2

9.${fn:split (str, ",") [i]} is divided by "," and the 2nd is removed;

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.