A JSP tag library, also called a custom label.
Application scope
JSP tags, mainly used in the foreground page, in JSP, if there is <%%> Java code in JSP, then for the foreground developer, need to understand Java code.
How to develop the foreground and do not understand the Java code, the cooperation of development?
In the front page, most of the code is Html+css+javascript, suddenly a lot of Java code, it really makes people very embarrassed.
By introducing tags, some of the commonly used Java code is organized into something similar to <> in HTML. In front of the developer, it is better to look at a specific number of tags than Java code.
After all, what is JSP? The JSP is the servlet when the server starts, it compiles all the JSPs into *.class files. However, in this process, the JSTL tag also generates the corresponding Java code.
Now look at the classification of the tag library:
Core Tag Library
Format Tag Library
Function Tag Library
Database Tag Library
i18n Formatting Tag Libraries
1 , introduce Jar Package
Use of Tag libraries
2 , in JSP To use the tag library on the page, you first need to introduce the tag library.
in the JSP the first plus:
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
Content from:
With the above settings, you can directly use the
The use of the process involves the value of the data, that is, from the Request gets the data. The EL (expression Language) expression can be used at this time .
El Language Introduction The El language is a representation of the JSTL output (input) of a Java expression. In Jstl, the El language is used in the Jstl attribute value. The El language can only be called by establishing an expression ${exp1} .
Use Tags:
Eg:hello ( using Tags ): <c:out value= "${hello}" ></c:out><br>
The specific use of the label, because too much, but also quite regular, in the process of Use please refer to the API documentation.
Of course, in some mature frameworks, there are also some tag libraries, because the framework of their own integration, so the framework of compatibility will be better. in General, using a tag library to encode can simplify the page. Makes the code simple and easy to read.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Javaweb_ using the tag library to simplify JSP