JSTL Common Tag Library Introduction

Source: Internet
Author: User
Tags control label

recently in the development of often use JSTL label, feel good to use, here are a few more commonly used Jstl label, for everyone to reference, but also the review of their own knowledge and review it!

The first one is the if in the Process Control label, which is used very much. Specific wording:

<c:if test= "Conditions" > Execute statements </c:if>
For example, Condition 1 is established, a button is displayed, Condition 2 is set up to display a hyperlink:

if you want to make logical judgments, use and and OR, this and Java && and | | Different, at first I thought it was Java, and then I knew it wasn't.
If there are many conditions, can it be judged like if ElseIf else in Java? The answer is, of course, OK:

Use the <c:choose></c:choose> inside the set <c:when test= "" ></c:when> make multiple statements of judgment can

<c:choose>    <c:when test= "${score>=90}" >    your score is excellent!    </c:when>    <c:when test= "${score>=70 and Score<90}" >    your score is good!    </c:when>    <c:when test= "${score>60 and Score<70}" >    your grades are passed    </c:when>    <c:otherwise>    Sorry, you didn't pass the exam!    </c:otherwise></c:choose>
Process Control label is finished, in said Loop label, here to say aForEach

Over hereAllproducts is a collection of products that contains a lot of product, loops through each element in it, and puts it in a checkbox to achieve a multi-marquee effect.
<c:foreach var= "Product" items= "${allproducts}" >    <label class= "checkbox inline" >        <input Type = "checkbox" Name= "ProductId" value= "${product.id}" >${product.name}    </label></c:forEach>
<c:forEach> tags can also be addedvarstatus= "idx" and then inside we can make judgments like${idx.index>0} or${idx.index++}
To get the length of a list collection, you can use the FN function

to import Tags: <%@ taglib prefix= "FN" uri= "http://java.sun.com/jsp/jstl/functions"%>






JSTL Common Tag Library Introduction

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.