In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "template library and tag library in JSP how to achieve", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "JSP template library and tag library how to achieve" this article.
The planning and design of tag library is very important in the whole system design, which is related to the degree of code reuse and the efficiency of system operation. Its planning should follow the following principles.
1) static HTML should be included as little as possible in tags. For the average user, the label is transparent. Users cannot view and modify tags. If too many static HT-ML statements are included in the tag, it will affect the user's modification and improvement of the static effect of the page, and restrict the use of the tag.
2) increase the reuse of the code as much as possible. In the classification of JSP applications, the common JSP applications are extracted as far as possible to form tags. Instead of implementing the application repeatedly in each tag. In this way, when you want to modify and improve the application in the future, you only need to modify this label, which is easy to maintain the code.
3) convenient for users to use. When designing the tag library, the usage of users should be fully taken into account, so that users can easily and easily understand and use tags.
Definition of ① tag library: to define a tag library, you must first define a tag library description file (TLD). This is a XML-based script file, which defines the version of XML, the encoding used, the version of the tag library, the version of the JSP used, the name of the tag library, and the definition and parameter description of all the tags contained in the library, including the name of the tag, the Java class corresponding to the tag, the description of the tag, and so on.
Implementation of ② tags: a tag is a special Java
Class, which must inherit the TagSupport class, which is defined in the javax.servlet.jsp.tagext package. In the tag class, it contains the parameter initialization method (Set/Get) for this tag, the body handling method (Handler) for the tag, and the methods for the next level tag to call, and so on.
Implementation of the ③ template: a template is a JSP file that contains tag references. In order to reference the defined tag in the template, you must first introduce the tag library.
<% @ taglib uri= "tag.tld" prefix= "ctag" >
Where uri specifies the path to the tag library description file; prefix specifies the prefix to use when referencing the tag.
When referencing the specified tag in the template, specify the name of the tag using the prefix specified when introducing the tag library; assign values to the parameters of the tag.
These are all the contents of the article "how to implement template Library and tag Library in JSP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.