JSTL parsing -- 002 -- core tag library 01

Source: Internet
Author: User
Tags tld

For versions earlier than javaEE5, You need to reference JSTL-related jar packages and tld files. After JAEE5, you don't have to worry about this. If you still cannot use it, download it from the official website (jstl. jar and standard. jar) The two jar packages put the corresponding tld file under the root directory of the project. The core tag library is the core tag library of JSTL, or the basic tag library, the most basic functions are implemented. The following is an example: 1. When the <c: out/> label shows out, you should be able to guess what the output means. In this case, the out tag is used to output data, the following is a simple example.

<Span style = "font-family: SimSun; font-size: 14px;"> the action parameter is: <c: out value = "$ {param. action} "> </out> </span>
Isn't it easy? First, let me explain: out is the Tag Name and value is its attribute. Do some new users not know $ {param. action? This is an EL expression. If you are interested, I will explain it separately later. The actual effect of this expression is the same as that of request. getParameter ("action. In fact, the out Tag also has the default and escapeXml attributes, Where default is the default value, if the default value is output without the value attribute, if excapeXml is true (excapeXml is true by default ), the output content will be encoded in xml format (note that only special characters such as "&", "<", and ">" will be encoded). Is it a bit dizzy for some students? For example, <c: out value = '$ {"<>"}'/> do you know what the output is? Yes & lt, & gt, and $ {"<>"} directly outputs <>. This is a magic thing. It seems useless. You can knock on the code on your computer. 2. The <c: if/> label is the condition judgment label in JSTL, it is equivalent to the if condition judgment in java <c: if test = "{param. action = 'ceshi'} "> your content </c: if> when param. if the value obtained from the action is ceshi, it is true. Therefore, the content in the result will be output. Note: <c: if test = "{1 = 1}"> the condition is false </c: if> <c: if test = "$ {1 = 1}"> the condition is true </c: if>. For this reason, you can find out why? If else exists in java, is there a <c: else> label? The answer is no. What should I do if I want to implement this function? Solution: <c: choose/>, <c: when/>, and <c: othsewise> help you solve the problem. Usage: <c: choose> <c: when test = "$ {param. action = 'ceshi'} "> when TAG output </c: when> <c: otherwise> otherwise output </c: otherwise> </c: choose> is it really tough? If you are interested, please wait for further explanation.

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.