Java_web Learning (5) JSTL standard tag library, java_webjstl

Source: Internet
Author: User

Java_web Learning (5) JSTL standard tag library, java_webjstl
1. What is JSTL?

The JSP standard tag Library (JSTL) is a collection of JSP tags, which encapsulates common core functions of JSP applications.

JSTL supports common and structured tasks, such as iteration, condition judgment, XML document operations, international tags, and SQL tags. In addition, it also provides a framework to use custom labels integrated with JSTL.

Based on the functions provided by the JSTL tag, it can be divided into five categories.

  • Core: the core tag library, which focuses on our learning;
  • Format tags: you only need to learn two tags;
  • SQL tag (SQL): Database tag library, which is out of date;
  • XML tags do not need to be learned. They are outdated.
  • JSTL Functions
2. Download JSTL

I recommend you download it from apache.

Http://tomcat.apache.org/taglibs/

Click the URL to go to this page.

Select [Standard] to go

Next, download the four taglibs.

 

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

4. Common core tag library labels:

<C: out>: label used for display

<C: set>: tag used for value assignment

<C: remove>: The tag to be deleted.

<C: catch>: tag used to capture exceptions

<C: forEach>: Used to traverse the labels of objects cyclically.

 

 

5. Compared with code 5.1, the code before JSTL was not used.

1. Pilot package

2. <%> get the request object

Analysis: this interface is not neat enough, which is not conducive to front-end workers beautifying the interface. Our goal is to enable front-end workers to focus on the beautification of the interface and avoid backend code interference.

5.2 use the code after JSTL

Summary

1. Do not import packages

$ {Table_1} is directly replaced

<% @ Page import = "java. util. List" %>

<% @ Page import = "entity. House" %>

<% List <House> houseList = (List) request. getAttribute ("table_1"); %>.

 

$ {Table_1} in this example}

In fact, it is written as follows: $ {requestScope. table_1}

 

Principle EL expression, which can directly take the variable in the request range

EL expression, which defines multiple implicit objects.

 

5.3 key code analysis

 

 

 

 

Thank you for being so handsome. You can take the time to read my essay! I am a beginner in Java. Please give me some advice and ask questions.

 

 

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.