Learning the basics of JSP custom tags
In the actual development, for example, in order to simplify a large number of JSP scripts in JSP, we need to use standard tag library and El expression, but the tags provided in the new tag library are limited and can not fully meet the needs of development. Such as paging. Therefore, you need to learn how to customize your own label library.
If you want to implement custom labels, you need the following steps:
Writing label processing classes requires inheriting or implementing related classes or interfaces
Write a label description file, which is an XML file and must be placed in the WEB-INF directory of the website
The tag is introduced into JSP and the tag library is introduced using the taglib instruction, and then used.
Class system of self label
Learn more about the following classes and interfaces:
---|Jsptag interface
This interface is a typical tag interface. The main tag is that the class that implements the interface can handle tags. Seralizable
----|Tag interface
The interface mainly describes the commonness of tag processing classes, but the class implementing the interface cannot process the tag body. The interface defines the communication protocol between tag processing classes and JSP pages. It also provides life cycle methods, such as methods that are automatically executed at the beginning and end of tags.
------|Tagsupport class
It is mainly responsible for handling the properties of tags.
-------|Bodytagsupport class
This class mainly deals with the tag body of the tag.
experience
1. Treatment
2. Description document
3. Introduction
JSP1. 2 carry out custom label development
Customize the label of a real date.
1. Implement a label processing class that can handle label attributes
2. Description document
3. Introduction and use
Implement custom label with label body
1. Label processing
2. Description document
3. Introduction and use
< date: showdate2 pattern = "yyyy MM DD" > system time: < / date: showdate2 >
The above is the whole content of this article. I hope it will be helpful to your study.