Wisdom Podcast Javaweb Day06-jstl

Source: Internet
Author: User

First, JSP tags (provided by sun Company)

Two, El expression

Third, Jstl (JavaServer Pages standard Tag library)

1. Why should there be jstl

The JSP tag is too weak, the El expression function is incomplete (such as cannot traverse the collection), all have jstl. The purpose is to cooperate with Jsp+el in the way of embedding Java code in JSP to improve the readability, maintainability and convenience of the program.

2. Jstl Essence and principle

The implementation of JSTL is equivalent to invoking a Java method in an El expression. First, define a class that contains a static method, define a TDL file to describe the function, and then reference the file with the Tablib directive on the page, and then you can call the function by prefixing it with a colon.

3.JSTL Five types of libraries (core tag libraries, internationalized tag libraries, database tag libraries, XML tag libraries, JSTL functions, where SQL tag libraries and XML tag libraries are not commonly used so do not learn)

3.1 Core Tag Library

3.1.1 C:out

3.1.1.1 Output Constants

3.1.1.2 Output variable

3.1.1.3 output default value (output default value if value is not value)

The 3.1.1.4 HTML Escape Output Ps:escapexml property controls whether to escape output by default value True

The JSP code is as follows:

<%@ page language= "Java"Import= "java.util.*" pageencoding= "Utf-8"%><%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%><%String Path=Request.getcontextpath (); String BasePath= Request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >; Pagecontext.setattribute ("Name", name); %> <c:out value= "${name}" ></c:out> default= "Obama (this is the default value)" ></c:out> <c:out value= "${name1}"default= "Obama (this is the default value)" ></c:out> View Code

Page effect:

3.1.2 C:set

3.1.2.1 setting or modifying the value of a property in a field

3.1.2.2 setting or modifying the attribute values of a map in a field

3.1.2.3 setting or modifying JavaBean property values in a field

3.1.3 C:remove Remove the value of a property in a domain

3.1.4 C:catch Catch exception

    

Wisdom Podcast Javaweb Day06-jstl

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.