JSTL tag library
So far, I have explained some basic principles and covered the EL syntax. I want to discuss four types of JSTL tag libraries. I mainly discuss the core library, because it must be used by you; however, I will also discuss the remaining several in detail so that you can start it.
First, although I should talk more about the two styles of the JSTL tag library, each of the above mentioned JSTL tag libraries appears in two versions: an expression that supports the limit Gate L; the other supports standard JSP expressions. When you introduce any tag library to a JSP page, you need to define a prefix that specifies the namespace corresponding to the tag in the library.
The four standard tag libraries and their JSTL standard-defined Prefix conventions are listed below. Remember: you can define your own prefix, but this is definitely no good.
Four standard tag libraries
To use the core tag library on the page (in fact, you make your page visible to the tag library namespace), you can add the following commands on your top:
<% @ Taglib prefix = "c" uri = http://java.sun.com/jstl/core %>
To use the tag library tag, add a prefix to each tag on your page using the prefix you designed in your include statement:
<C: out value = "$ {anExpression}"/>
Core database
Let's test the core database in more detail. Let's first look at its most common functions.
Display/set value and exception handling
The most basic mark of the core library is the c: out mark, which displays the value of an EL expression on the page. A c: out expression is usually like this:
We have <c: out value = "$ {applicationScope. product. inventoryCount }"
EscapeXml = "true" default = "0"/> of those items in stock.
In the above example, the value attribute is the expression that we send to the page output. I also explained the attributes and default attributes of the escapeXml option. The attributes of escapeXml specify XML characters (<,>, &, and .) whether it should be converted to the corresponding character entity code (so that they can make these characters appear in an HTML page ); the default attribute is used when EL cannot estimate the value or the value is calculated as null.
Note: When EL supports full JSP2.0, you do not need to use the c: out action. You can just nest JSP expressions directly on the page.
Another common core action is c: set, which sets a variable on the page. You can use the c: set action in two ways. The first method is to set the variable defined in the var attribute to the value defined in the value attribute. The method is as follows:
<C: set var = "customerID" value = "$ param: customerNumber" scope = "session"/>
The scope attribute specifies that the customerID variable is set within the session period. If the range is not specified, the default range is page.
Another powerful purpose of c: set is to assign the content of the body marked by c: set to a specified variable:
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.