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.