Jstl Tag Library: JSTL Usage Summary (1) Core Tag Library

Source: Internet
Author: User
Tags foreach object end sql range tld

Jstl is the standard tag Library of JSP, he provides many very useful functions, eliminates our custom label the trouble, thus achieves in the JSP page no scriptlet effect.
Jstl is only convenient for us to develop, if not used, will not hinder our development, the general Jstl is used in conjunction with the expression language.
First, JSTL configuration
Put the Jstl.jar into the tomcat\lib and put the TLD file in the Jstl.jar into the Web-inf, and the TLD files he provides are:
(1) C.tld core Tag library, provide such as iterative output and other operations.
(2) Fmt.tld The format of the operation.
(3) SQL.TLD provides SQL query, update and other operations.
(4) X.TLD provides XML operations.
(5) Fn.tld provides a string of function operations, such as contains, StartsWith, and other operations.
Second, the core tag library
1.<c:out>
For output, the general structure is as follows: <c:out value= "" escapexml= "" default= ""/>
Value represents the values that need to be exported;
EscapeXML said the need to convert similar < to "<";
Default indicates that the statement is output if value is null;
2.<c:set>
Used to set built-in object properties or custom object properties, the general structure is as follows:
(1) <c:set var= "" value= "" scope= ""/>
var represents the name of the property;
Value represents the values of the property;
Scope represents the range of storage;
(2) <c:set target= "" property= "" value= ""/>
Target represents the object name;
property represents the attribute name;
Value represents the values of the property;
3.<c:remove>
Used to remove the built-in object properties, the general structure is as follows:
<c:remove var= "" scope= ""/>
var represents a property name;
Scope represents the range of attributes;
4.<c:catch>
Used to catch exceptions, similar to Try-catch; The general structure is as follows:
<c:catch var= "" >
Statement
</c:catch>
var is used to hold the information of the exception;
5.<c:if>
Like an if statement, the general structure is as follows:
<c:if test= "var=" "scope=" ">
EXECUTE statement
</c:if>
test indicates judgment;
var indicates preservation of judgment result;
Scope Indicates the extent of the result preservation;
6.<c:choose>
for multiple judgments; The general structure is as follows:
<c:choose>
<c:when test = "" > <!--used to judge-->
Statement
</c:when>
<c:when test = "" >
Statement
</c:when>
<c:otherwise> <!--When all of the when is not established, enter-->
Statement
</c:otherwise>
</c:choose>
7.<foreach>
For iterative output, the general structure is as follows:
<c:foreach items= "" var= "[begin="] [end= "] [step="]]>
${var}
</c:forEach>
Items represent the set of outputs;
var represents the element of an iterator;
Begin indicates which index to start from;
End indicates to which index ends;
Step represents the interval of output; This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20121119/33954.html

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.