A 3-step configuration is required before using the Struts label.
1. import TLD files.
2. Register the tag library in Web. Xml.
3, introduce the tag library in the page.
The above steps are described in detail below.
1 Import the TLD file.
TLD files are struts's tag library profiles, which are typically copied directly to the Web-inf directory of the Application project.
2 Register the tag library in Web. Xml.
Using the logical reference method in the JSP file to point to the actual tag library, this mapping is achieved through Web. Xml. The name of the tag library and the actual stored URL address are configured in Web. XML, such as:
3 Introduce the Tag library to the page.
Use the <taglib> tag in the JSP page to introduce a tag library, and give it a valid prefix for the page as a token, and then use the tag library by its prefix, just declare the following in the JSP page:
In the above code, for example, the prefix of the bean tag library is defined as a bean, the bean tag library can be referenced by a prefix bean, as in the following example:
The two Jstl tag libraries can be divided into the following categories:
1. Core Tag Library
2. Internationalization label
3. Database tags
4.XML Label
5.JSTL function (El function)
Now the most used are: the core tag library and the JSTL function library, the other three kinds of tags are not very common (almost discarded).
Let's take a look at Jstl's core tag library, we need to import two Jar:jstl.jar and Standard.jar when using the JSTL tag library
The core library is C.TLD, the function library is fn.tld, and we can use these tags to describe what tags are available in the document, and how they are used
C.tld the URI of the label description file is Http://java.sun.com/jsp/jstl/core
Fn.tld the URI of the label description file is Http://java.sun.com/jsp/jstl/functions,
So if we want to use this tag, just introduce it in the JSP:
For example, you can use the prefix C to refer to the JSTL tag library, to achieve the word super-line folding problem:
Basic usage of Struts and jstl tag libraries