JSP Tag Library Introduction (1) What is the label library?

zhaozj2021-02-08  211

The JSP tag library (also known as custom label) is a method of generating an XML-based script through JavaBean. From the concept, the label is a very simple and reusable code structure. For example, in our latest JSPKIT (in JSP Insider), we use the XML tab to make a relaxed access to the XML document. Please see the following list A.

Listing A: Execute an example tag for XML / XSL conversion and its HTML page

<% @ Taglib Uri = "http://www.jaxpinsider.com/jspit/jaxp" prefix = "jaxp"%> C: / xml/example.xml C: /Xml/example.xsl

The above examples use simple tags to access more powerful code at the behind-the-scenes. A XML file is first loaded in the above case, then applying an XSL file to create a result that will be sent to the client - all this is just just a simple label.

Customized tags make it easy to create reuse open source modules in the JSP project. And all of your needs is just the label library and its documentation. The important feature of the label library is as follows:

Easy to install on multiple projects is easy to migrate from a JSP project to other projects. Once a label library is established, you only need to pack this tag library into a JAR file to reuse in other JSP projects. Can not be reused is what you are adding tag as a programmer in establishing a label. Because tags can be reused, the label library can easily use your own project. Currently, the best label resources can be found at the site of jsptags.com. The extended JSP label library can have any features and features in the JSP specification (JSP 1.2). This also means that you have an unlimited ability to expand and increase the powerful features of JSP, but there is no need to wait for the new version JSP release. So, you can completely cancel the JSP Include call on the page - you can use the include label to build your own specification. Easy to maintain the label library makes JSP web applications easily maintained. There are several reasons:

Labels are easy to use for anyone, easy to understand. All your logic resident in the center of label processor and Javabean. In this way, if you have to update your code, you only need to handle these central files without fixing other pages that use these code. If you need to add new features, you don't have to change any already existing pages. You can include additional properties into your tag to introduce new behaviors while reserving the previous properties, implementing the normal operation of the old page. For example, you may have a label, which makes your text display blue: my text But as the project is going, you want to make the blue darken. So you keep your own label but add a new attribute: shade my text All old tags continue to display blue, but now you can use the same label to generate change Dark blue text. The label improves the reuse of the code. The code that has been tested and used must have fewer bugs. Therefore, the JSP page with custom labels also has fewer defects, which is naturally more convenient to maintain.

Faster development speed label library is a good way to reuse code. We know that the reuse of the server-side language standard is used to use the template. There is much better than this way of label libraries and template libraries. With the template library, you need to modify the template or build a hard interface for each project. The label library does not have these limits, while the object-oriented characteristics of the label make the label library not only use flexible and the extension capacity is extremely powerful. Also, because you reuse the code, the result is greatly reduced during project development, and more time can be used to design your web application. The simple interface of the label library makes these code simply, easy to debug. Although the label library is particularly simple, it is more complicated than the establishment of simple JavaBean complicated. The main reason for this complexity is that the label library contains several parts. And the skills you need to master is just understanding, familiar with Java and JSP.

转载请注明原文地址:https://www.9cbs.com/read-2300.html

New Post(0)