JSP-10-JSTL standard label library, jsp-10-jstl label Library

Source: Internet
Author: User
Tags i18n

JSP-10-JSTL standard label library, jsp-10-jstl label Library

JSTL (jsp standard tag Library) contains a set of standard tags used to compile and develop JSP pages. It provides users with a script-free environment.

JSTL provides four major tag libraries: Core tag library, International (I18N) and formatted tag library, XML tag library, and SQL tag library.

 

 

 

1. Core tag Library

Advantage: You can view the source code.

In the core tag library, tags are used to operate the range variables created on the JSP page. The condition tag is used to determine the conditions for the code on the JSP page, and the two iteration tag is used to traverse an object set cyclically.

Ø General labels <c: set>:

This is a variable in the webpage. If the variable does not exist, create it.

<C: set var = "uid" value = "value" scope = "page/request/session/application"/>

<C: remove>

Used to delete the created variable

<C: remove var = "varname" scope = "page/request/session/application"/>

<C: out>

Calculates the expression result and stores the result in the current jspWriter object.

<C: out value = "value" escapeXML = "true/false" default = "defalutValue"/>

Where:

Value: an expression.

EscapeXML: determines whether to convert the characters (such as ><&) in the result to the instance code. The default value is true;

Default: default value (if the result value is NULL)

 

Ø condition tag <c: if>

<C: if test = "condition" var = "varName" scope = "page/request/session/application">

Body Content

</C: if>

Where:

Test: Specify the condition

Var: name of the variable for the test condition

Scope: Specify the range of var

 

<C: choose>

Similar to swich statements in java

<C: choose>

<C: when test = "condition 1">

Method body 1

</C: when>

<C: when test = "condition 2">

Method Body 2

</C: when>

<C: otherwise>

Method body 3

</C: otherwise>

</C: choose>

Ø iteration tag <c: forEach>

Used to repeat the nested tag body content in each object set

<C: forEach var = "varName" items = "conllection" varStatus = "varStatusName" begin = "begin" end = "end">

Body content

</C: forEach>

Where:

Var: Specifies the name of the exported range variable.

Items: Set of objects to be traversed

VarStatus: Specifies the name of the range variable for the traversal status.

Begin: The index to start traversing

End: The index that ends the traversal.

 

<C: forTokens>

<C: forTokens items = "StringofToken" delims = "delimiters" var = "varName" varStatus = "varStatusName">

Body Content

</C: forTokens>

Where:

Items: value to be traversed

Delims: Specifies the characters used to separate the tokens in a string.

Var: specify the name of the range variable for the traversal object

VarStatus: Specifies the name of the range variable for the traversal status.

 

2. International and format tag Libraries

I18N and formatted tag libraries can be used to create internationalized Web applications that standardize the output of numbers and date-time.

<% @ Taglib url = "http://java.sun.com/jstl/fmt_rt" prefix =" fmt "%/>

 

<Fmt: setLocale>

Used to override the region settings specified by the client

<Fmt: setLocale value = "setting" variant = "variant" scope = "page/request/session/application"/>

Where:

Value: contains a language code containing lowercase letters and a country code containing two uppercase letters. The language and country code should be separated by a hyphen or underscore.

Variant: browser-specific variables (optional)

<Fmt: bundle>

Create an I18N local context and load its resource package to it. The resource package name is specified by the basename attribute of the <fmt: bundle> label.

<Fmt: bundle basename = "basename">

Body content

</Fmt: bundle>

<Fmt: message>

Used to give the output value of the resource package

<Fmt: message key = "messageKey"/>

<Fmt: formatDate>

<Fmt: formatDate value = "date" pattern = "yyyy-MM-dd HH: mm: ss"/>

 

Related Article

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.