Javaweb_ using the tag library to simplify JSP

Source: Internet
Author: User

JSP Tag Library. Also call yourself to define the label.

Application scope

JSP tags. Mainly applied to the foreground page. In the JSP. Assume that Java code such as <%%> exists in the JSP. Well, for the front-desk developers. You need to understand Java code.

How to develop the foreground and do not understand the Java code, the cooperation of development?

In the foreground page, most of them are Html+css+javascript code. All of a sudden a bunch of Java code, it really makes people very embarrassed.

Introduce tags. is to sort out some of the frequently used Java code into something like <> in HTML.

In front of the developers, it is better to look at a specific number of labels than Java code.

Say exactly. What is a JSP? The JSP is the servlet when the server starts. All of the JSP compiled into a *.class file.

However, in this process, the JSTL tag also generates the corresponding Java code.

Now look at the classification of the tag library:

Core Tag Library

Format Tag Library

Function Tag Library

Database Tag Library

i18n Formatting Tag Libraries

1 , introduce Jar Package

Use of Tag libraries

2 , in JSP in order to use the tag library in the page, we need to introduce the tag library first.

in the JSP the first plus:

<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>  

Content from:

With the above settings, you can directly use the

The use of the process involves the value of the data, that is, from the Request gets the data. The EL (expression Language) expression can be used at this time .

El Language Introduction The El language is a representation of the JSTL output (input) of a Java expression.

In Jstl, the El language is used in the Jstl attribute value.

The El language can only be invoked by establishing an expression ${EXP1} .

Use Tags:  

Eg:hello ( using Tags ): <c:out value= "${hello}" ></c:out><br>

The detailed use of the label, due to too much, and also quite regular. Please refer to the API documentation in the process of use .

Of course in some mature frameworks, there are also some tag libraries, due to the framework of their own integration. So it's better to be compatible with the framework.

In general, using a tag library to encode can simplify the page.

Make the code. Simple and easy to read.

Javaweb_ using the tag library to simplify JSP

Related Article

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.