Basic usage of Struts and jstl tag libraries

Source: Internet
Author: User
Tags tld

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

the URI for the FN. TLD 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.