Jsp jstl label language library and jspjstl label

Source: Internet
Author: User

Jsp jstl label language library and jspjstl label

The el language $ {} is used by default in jsp. I didn't expect jstl labels to be unavailable in jsp. You need to import jstl. jar and standard. jar to identify and use them.

If jsp is used in development, the tag language must be used, because apart from static html content, other data obtained from the background database usually needs to be converted and judged.

There is a c. tld file in standard. jar;

This should be <% @ taglib prefix = "c" uri = "https://java.sun.com/jsp/jstl/core" %>, which is the tag definition in the core tag library.

After the core tag is introduced, the following available labels are available:

Label description
 
  
Used to display data in JSP, just like <% =...>
  
   
Used to save data
   
    
Used to delete data
    
     
Used to handle exceptions that generate errors and store error information
     
      
Same as if in general programs
      
        Only
       
         And
        
          Parent tag
          
          
            To determine whether a condition is true.
            
            
              Sub-tag, connected
             
               After the tag, when
              
                Executed when the tag is determined to be false.
               
                 Retrieve an absolute or relative URL and expose its content to the page
                
                  Basic iteration tag, accepting multiple Collection types
                 
                   Separate the content based on the specified separator and iterate the output
                  
                    Used to pass parameters to pages that contain or redirect
                   
                     Redirects to a new URL.
                    
                      Use optional query parameters to create a URL
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   
  
 

I don't know if there will be any overlap with the Tag feature provided by jsp, but I usually like to use jstl.

Let's take a look at the most common if label definition:

  
     
  
       Simple conditional tag, which evalutes its body if the    supplied condition is true and optionally exposes a Boolean    scripting variable representing the evaluation of this condition    
      
  
   if
      
  
   org.apache.taglibs.standard.tag.rt.core.IfTag
      
  
   JSP
              
  
   test
          
  
   true
          
  
   true
      
  
   boolean
                  
  
   var
          
  
   false
          
  
   false
                  
  
   scope
          
  
   false
          
  
   false
        
 

The top to bottom means:

Description: description, which is not translated in English.

Name: the name of the tag. You can use

Attribute: attributes that can be used by tags, including test \ var \ scope.

Test is the condition for judgment,

Var is the result after judgment. It is true or false. The value of var is used to store the result, and then the result can be obtained through this value.

For example, if var = "test", you can get the test result from $ {name }.

Scope. jsp has four scopes: request, session, and put one: scope = "request"

False is not required.

The content between the start and end tags of if is determined based on the true and false values of test.

Next:

Out tag Definition

  
     
  
           Like <%= ... >, but for expressions.    
       
  
   out
      
  
   org.apache.taglibs.standard.tag.rt.core.OutTag
      
  
   JSP
              
  
   value
          
  
   true
          
  
   true
                  
  
   default
          
  
   false
          
  
   true
                  
  
   escapeXml
          
  
   false
          
  
   true
        
 

Value is required. Generally, its value is an el expression, otherwise it is static content.

Default value. If the value cannot be obtained, the default value is displayed,

EscapeXml specifies whether the content is displayed in plain text. The default value is true. If this attribute is available, HTML text is displayed.

The content between the out labels is not displayed.

All right, all content is finished!

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.