JSTL Tag library :

JSTL: JSP Standard Tag Library

effect : and 【EL coordination 】 Use , It allows users to 【 Use... As little as possible java Source code 】.

1, Import jar package

Import ( Copy and paste... Into the project lib Catalog )jstl Of jar package . jstl.jar  standard.jar

2, hold JSTL Import tag library into jsp On the page

Use jsp Medium taglib Instructions , Bring the tag library into :

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

Be careful : Prefix to avoid duplicate tags written by others .

prefix="c" It's equivalent to giving this tag library an alias , In the future, it will be used to c Use the tag in the tag library with the tag at the beginning . This alias can also be called other names .

<c:forEach> label

Loop traversal operation ,【 The highest usage rate 】.

Use <c:forEach> label 【 Complete code 】 Traverse

<c:forEach var="stu" items="${list }" begin="0"  end="3" varStatus="status" step="1">

varStatus Represents the state of the loop , use status Express .

step It's skipping a few at a time , The default value is 1, One by one .

Items: Traversal object

Var: The name of the traversal result

General traversal just write var and items Just a property .

【 Traverse List aggregate 】:


<c:forEach items="${list }" var="stu">


<td>${stu.id }</td>

<td>${stu.name }</td>

<td>${stu.age }</td>




【 Traverse Map aggregate 】:

<c:forEach items="${map }" var="entry">

${entry.key }-->${entry.value.id }

${entry.value.name }   ${entry.value.age }<br>


<c:if> label :

<c:if test="${score>85 }">



This is equivalent to :




<c:choose> label

<c:when> label

<c:otherwise> label


<c:when test="${score>=90 }"> optimal </c:when>

<c:when test="${score>=80 }"> good </c:when>

<c:when test="${score>=70 }"> in </c:when>

<c:when test="${score>=60 }"> pass </c:when>

<c:otherwise> Bad </c:otherwise>


amount to :


}else if(score>=80){

}else if(score>=70){

}eles if(score>=60){



jap piece And JSTL More articles on tag library

  1. JavaWeb Learning chapter ---- Custom tag &amp;&amp;JSTL Tag library details

    Today, let's take a look at the content of custom tags , Custom tags are JavaWeb A very important part of the core functions of , We said before ,JSP The norm is very clear , Namely Jsp It is forbidden to write a line in the page Java Code , It's better not to have Java Script snippets , below ...

  2. Java The third stage of learning ( fourteen 、JSP Dynamic pages 、EL expression 、JSTL Tag library )

    One .JSP technology 1.jsp Scripts and comments jap Script : 1)<%java Code %> ----- Inside java Code translation to service Inside the method , For example, it's written in doget.dopost Code in 2) ...

  3. It's personal jsp、EL expression 、JSTL Notes from the tag library , Less concepts, more practical , If you need to leave your mailbox , The manuscript will be shared at the first time PDF For everyone !

    jsp Chapter one jsp Introduction and comparison servlet effect : Dynamic web page technology , Get data from database dynamically jsp and servlet Advantages and disadvantages : jsp advantage : Page performance is convenient , Good for writing html Code jsp shortcoming : Business logic processing ...

  4. web Development ( 7、 ... and ) JSTL Tag library

    I saw a good article on the Internet , Write in detail . The following is a quote from that blog post . Reproduced in <http://www.cnblogs.com/whgk/p/6432786.html>, This is for reference only . One . Why? ...

  5. JSP、EL expression 、JSTL Label store dry goods ( Recommended collection )

    JSP(Java Server Pages) Be similar to ASP technology , It's on traditional web pages HTML file (.htm,.html) Insert Java Procedures section (Scriptlet) and JSP Mark (tag), Thus forming JSP file , ...

  6. To relive JSP Learning notes --JSTL Tag library

    I used to write jsp The time is right jstl There are some conflicting labels , Because I feel like java The way the code is written is almost invincible , There's no need to use tag libraries , But this review is still a good study , It's useful to find this , Good use can save a lot of work ,JSTL yes ...

  7. Simple and practical JSTL Tag library

    1. JSTL What is a tag library ? Simply speaking , With it, you can be in a similar HTML Of JSP The page uses some advanced grammar , Implement iteration . conditional .XML The document operation . International label .SQL label . 2. How to use ? Refer to the website ...

  8. JSTL The core tag of tag library

    One .JSTL Tag library Introduction JSTL Tag libraries are used to make up for html The lack of labels , It was born of standardizing the use of custom tags . Use JSLT The purpose of the label is not to jsp The page appears java Logic code Two .JSTL Classification of tag library The core ...

  9. Customize jstl Tag library

    development environment :Spring+SpringMVC +Maven +Mybatis JSTL Tag library configuration : Import corresponding jstl.jar and standard.jar , The configuration I use is as follows : <prop ...

Random recommendation

  1. 《 Serial | The Internet of things framework ServerSuperIO course 》- 6. Concurrent communication mode development and precautions

    1.C# Cross platform Internet of things communication framework ServerSuperIO(SSIO) Introduce < Serial | The Internet of things framework ServerSuperIO course >1.4 A communication mode mechanism . < Serial | The Internet of things framework Serve ...

  2. EditPlus 3.7.164 Chinese version (4 month 3 Daily update )

    The new version of the Chinese can not be before the Chinese part of the content , And fixed some problems of the old Chinese version . Welcome to download the new translation .

  3. JSON One of the studies

    1.JSON:JavaScript Object Notation(javaScript Object notation ),JSON Is the syntax for storing and exchanging text information , similar XML:JSON Than XML smaller , faster , Easier to parse : { &qu ...

  4. How to be in Linux On the use of SQL Statement to query Apache journal

    Linux There is a remarkable feature , Under normal circumstances , You can know what's going on in your system through log analysis system log , Or what's going on . You bet , System log is the first-hand resource that system administrators need to solve system and application problems . We will be in this article ...

  5. adobeMediaServer

    Reference address : http://www.piis.cn/news/new519.asp http://www.cuplayer.com/player/PlayerCode/RTMP/2012/0918427 ...

  6. posix thread Condition variables,

    summary The wait condition variable always returns the locked mutex . The function of conditional variables is to send signals , Not mutually exclusive . The shared data associated with conditional variables is “ The predicate ”, If the queue is full or empty . A conditional variable should be related to a predicate . If a conditional variable is associated with multiple predicates ...

  7. 【 primary 】Object Abnormal static state

    // All classes inherit Object class : Object a=; Object b="ddfasfda"; // Under normal circumstances , Will be omitted :Object: But it actually exists : class tes ...

  8. QTabWidget and QTabBar. The color setting of the text , Three methods

    see the code after subclassingTabWidget::TabWidget(QWidget *parent): QTabWidget(parent),mousePressFl ...

  9. ng-transclude

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. django Use of labels

    First, rebuild a common Of app Then create __init__ send common Become a bag     Be careful templatetags Names make fixed And create one below named fitter Filter Registration filter app htm ...