The use of C tag in JSP personal summary __js

Source: Internet
Author: User

The C tag we use in web development is the core library in Jstl, providing common support for everyday tasks

<C:SET>: Setting variable values and Object properties

<c:set value= "value var=" variable name "scope=" variable's scope "target=" Object name property= "object property name" ></c:set>

<C:OUT>: Display variable contents in page

No label body:

Has the label body:

<c:out value= "value" escapexml= "{true|false}" default= "Default Value" >  label Body </c:out>

Conditional label:<c:if> <c:choose> <c:when> <c:otherwise>

No label body:

<c:if test= "test condition" var= "variable name" [scope= scope]/>      

Has the label body:

<c:if test= "test condition" var= "variable name" [scope= scope]>       


<c:when> <c:otherwise> cannot be used alone and can only be used as a child label for <c:choose>.

These three tags combine to implement the functionality of the switch statements in Java. The syntax is as follows:

    <c:choose> 

        <c:when test= "${user.class== ' guest '}" >
             tag body 1  

        </c:when> 

        <c:when test= "${user.class== ' VIP '}" >

            label body 2 

       </c:when>    

       <c:otherwise> 

            label Body 3 

       </c:o Therwise>    
    </c:choose>  

Iteration Label:

<c:forEach> <c:forTokens> to traverse an object collection

<c:foreach var= "variable name" items= "collection" varstatus= "Traversal state name"   begin= "Begin" end= "End" step= "Step" > 

       label body

</c:forEach>


<c:fortokens>: Used to traverse a string, and each traversal result returns a word in the string.

<c:fortokens items= "string" delims= "delimiter" var= "variable name" varstatus= "Traversal state name" begin= "Begin" end= "End" step= "Sep" > 

       tag Body

</c:forTokens>


<c:url>: Used to encode URL addresses.

Has the label body:

<c:url value= "url" context= "path" var= "variable name" scope= "Scope" >  

The following code:

  <c:url value= "http://localhost:8080/el/index.jsp" var= "Newurl" >

       <c:param "name" name= "Zero"/ > 

        <c:param name= "age" value= "/> 

 </c:url> 

<a href=" ${newurl} "> Dot me </a>

Generated url:http://localhost:8080/el/index.jsp?name=zero&age=28

No label body: used primarily for editing context URLs.

<c:url value= "url" context= "path" var= "variable name" scope= "Scope"/>      

The following code:

   <c:url value= "/logon.jsp" > Login </c:url>  

If the current path is El, the output is:/el/logon.jsp

。。。。。。

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.