Layered thought of "Java Technology drip"--jstl tutorial

Source: Internet
Author: User

What is it?

JSTL ( JSP standard TAGLIBRARY,JSP Standards Tag Library is a continuous improvement of the open source JSP standard Tag Library, is a standard of sun, by the Apache Jakarta team to achieve and maintain.


why not?

Use The biggest goal of JSTL is to help simplify the daily work of JSP page authors (this position is called pageauthor). Page author refers to the person responsible for implementing the Web application presentation layer using JSP. Many page author are not good at using any programming language.

page author faces the use of a scripting language (and therefore they are seen as a Java Programmer) to manipulate the requirements of the JSP page Dynamic Data, unfortunately Pageauthor had to face the complexity of the scripting language (Java code) that was not adapted to their needs

do what?

by avoiding scripting elements to simplify the use of Software maintenance for JSP applications

JSTL provides the following features:

( 1) General method

These methods complement the expression language, making a Pageauthor is an easy way to use expression language, set and delete property values for a JSP scope, or catch exceptions.

( 2) Process Control method

label-based control flow structure (conditions, iterators), for page authors more friendly

( 3) Tag Library authenticator (tag libraries Validators--tlvs)

TLVs allows programs to accept only specific tag libraries, and can also restrict JSP encoding format, free from the use of scripting languages.


How to use it?
JSTL and JSP

The use of JSTL is to introduce the corresponding tag library on the basis of JSP, simplifying the Java code appearing on JSP page, making the page more concise. Improve readability and maintainability of your pages.

JSTL and EL

El is a special general-purpose programming language in Java that draws on JavaScript and XPath. The main role is to embed the Javaweb application into a Web page (such as a JSP) to access the context of the page and the objects in different scopes, get the value of the object's properties, or perform simple operations or judgments. When an El obtains some data, it automatically converts the data type.

with the The jstl tag works together to represent complex behavior with simple and convenient symbols.

1. Grammatical structure

${expression},expression is similar to the use of objects, which can be obtained using the. operator (accessor), which is equivalent to the Java code <%=request.getattribute ("variable name accessed in Request") in the JSP Further encapsulation of > for easier use

2, support the use of operators

==/eq!=/ne </lt >/gt &&/and | | /or!/not//div%/mod

Classification

--need to introduce relevant implementation%@ Taglib uri= "..." prefix (prefix) = "C/FMT/FN"%> (1) core<c:out value= "" >  VS  ${el Expression} ①default②escapexml= ""  //whether parsing HTML strings <c:set>  VS  <c:remove> properties: Value,<c:if test>   --if<c:choose><c:when Test><c:otherwise><c:foreach Items var= "single element variable" varstatus= "Counter" begin= "" End= "" step= "" ><c:fortokens items delims var>--using strings with special symbol intervals  VS  fn:split (2) fmt<fmt:formatdate Value type Patten><fmt:formatnumber Value Patten: > (3) FN${FN: Function name ()} Custom Function--public static method, and TLD tag library file configuration

Summary

Ultimately, the introduction of JSTL of learning, in essence, or express the idea of layering, page layer development is to show the effect, and the background function implementation or is different, we can not expect the page developers can read Java code, in a cumbersome Java work on your own page development under the code. With the JSTL to a large extent, reduce the appearance of such a situation, reduce the page and background code coupling, development, maintenance is more efficient!



Layered thought of "Java Technology drip"--jstl tutorial

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.