JSTL using the configuration

分类:Web 2010-03-16 来源:CodeWeblog.com 人气:336

JSTL use a configuration summary

1.web.xml version 2.3 version of the configuration

Reference document: http://blog.csdn.net/tiancaoyan/archive/2009/06/10/4256637.aspx

Use of the environment: WebLogic92 + JDK1.5, web.xml version 2.3, that file is as follows:

<! DOCTYPE web-app PUBLIC "- / / Sun Microsystems, Inc. / / DTD Web Application 2.3 / / EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

Use these steps:

l copy jstl.jar, standard.jar files to Web-INF/lib directory

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

l If web.xml version 2.3, but also in plus: <% @ page isELIgnored = "false"%>

2 web.xml version 2.4 configuration

<Web-app version = "2.4"

xmlns = "http://java.sun.com/xml/ns/j2ee"

xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">

l copy jstl.jar, standard.jar files to Web-INF/lib directory

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

3 web.xml version 2.5 configuration

JSTL in J2EE5.0 has been included in standard specifications will be jstl.jar, standard.jar two jar files into jstl1.2.jar.

<Web-app version = "2.5"

xmlns = "http://java.sun.com/xml/ns/javaee"

xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

Web.xml above under the various versions of Tomcat6.0.24 can be displayed correctly.

Second, using the example of JSTL

JSTL access range.

Reference document: http://blog.csdn.net/tiancaoyan/archive/2009/06/10/4256637.aspx

An EL expression that contains variables and operators. Any stored in a JSP scope (eg: page, request, session, application) of the bean can be used as an EL variable. In addition, EL supports the following predefined variables:

Variable name

Explain

pageScope

A range that contains all page scope variables collection (a java.util.Map)

requestScope

A range that contains all request scope variables collection (a java.util.Map)

sessionScope

A range that contains all session scope variables collection (a java.util.Map)

applicationScope

A range that contains all application scope variables collection (a java.util.Map)

param

A collection that contains all request parameters (a java.util.Map), corresponding to each parameter by way of assignment of a String value

paramValues

A collection that contains all request parameters (a java.util.Map), corresponding to each parameter by way of assignment of a String array

header

1 contains all the information requested in the first set, (a java.util.Map), by each of the first information corresponding to a String value to assign values

headerValues

A header contains all the requested collection (a java.util.Map), through each header values are stored in a String array to assign values

cookie

A cookie contains a collection of all the requests (a java.util.Map), through each cookie (javax.servlet.http.Cookie) value corresponding to a cookie to assign values

initParam

Application that contains all the initialization parameters set (a java.util.Map), through each parameter corresponds to a String value to assign values

pageContext

A javax.servlet.jsp.PageContext instance of the class, used to provide access to different request data

Operator on the variables you describe the desired action. If you previously used any programming language, in the EL expression used in the operator for you may look familiar. Because they and those in most languages supported by the same operator.

.

Access a bean property or Map entry

[]

Access to an array or list element

()

Pair group expressions, used to change the assignment order

?:

Conditional statements, such as: condition? IfTrue: ifFalse. If the condition is true, the expression value of the former, whereas the latter

+

Mathematical operators, plus operation

-

Mathematical operators, by operation of a value or negated

*

Mathematical operators, by operation

/ Or div

Mathematical operators, in addition to operation

% Or mod

Mathematical operators, module operations (take over)

== Or eq

Logical operators to determine whether the equal sign ends around, if equal return true, otherwise it returns false

! = Or ne

Logical operators to determine whether the symbol is about equal at both ends, if not equal return true, otherwise it returns false

<Or lt

Logical operators to determine whether the symbols on the left than the right, if less than the return true, otherwise it returns false

> Or gt

Logical operators to determine whether the symbols on the left than the right, if more than to return true, otherwise it returns false

<= Or le

Logical operators to determine whether the symbols on the left is less than or equal to the right, if less than or equal to return true, otherwise it returns false

> = Or ge

Logical operators to determine whether the symbol is greater than or equal to the left of the right, if greater than or equal to return true, otherwise it returns false

& & Or and

Logical operator, and operation of Fu. If the same is true about both sides return true, otherwise it returns false

| | Or or

Logical operator, or operating Fu. If there are any left and right side of the true returns true, otherwise it returns false

! Or not

Logical, non-operating Fu. Check operation returns true if false, otherwise it returns true

empty

Used to determine an empty variable value: null, an empty String, empty array, empty Map, there is no entry in the Collection Collection

func (args)

Call the method, func is a method name, args is the argument, can not, or there is one more parameter. Parameters separated by commas

An EL expression can contain: numbers, text (in single quotes or double quotes), Boolean values, null values.

1 for a single object

<% Request.setAttribute ("username", "david")%>

$ (RequestScope.userName)

Two types of traversal Map

<%

Hashtable hashtable1 = new Hashtable ();

hashtable1.put (new Integer (1), "uno");

hashtable1.put (new Integer (2), "dos");

hashtable1.put (new Integer (3), "tres");

request.setAttribute ("numberMap", hashtable1);

/ / JSTL best value of the designated area to visit:

/ / $ (SessionScope. NumberMap2), $ (applicationScope. NumberMap2).

request.getSession (). setAttribute ("numberMap2", hashtable1); request.getSession ()

. GetServletContext (). SetAttribute ("numberMap3", hashtable1);

%>

<c:forEach var="month" items="${numberMap}">

<li>

$ (Month.key), $ (month.value)

</ Li>

</ C: forEach>

The JSTL tag related reference

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/xml" prefix = "x"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "f"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn"%>

本文关键词:
分享到:
blog comments powered by Disqus

相关文章

  • el expression jstl local tld configuration environment tomcat5.5 2010-09-27

    First, enable the EL expression can be if not involved directly in the jsp jstl header statement <%@ page isELIgnored="false" %> Also check the statement under the web.xml <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="

  • jstl the configuration 2010-08-12

    jstl configuration methods: 1, will be copied to the web-inf/lib jstl.jar and under standard.jar can (if only using the EL expression, without reference to these two packages) 2, the head of the introduction of taglib jsp page as follows: <% @ Tag

  • JSTL configuration considerations 2010-12-20

    When configuring the JSTL today encountered a small problem Is JSTL1.0 and JSTL1.1 Configuration, some differences ( Nonsense, of course, there are differences between the ) jstl1.0 <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> j

  • JSTL configuration problem: According to TLD or attribute directive in tag file (change) 2009-02-09

    Application deployment occur when running JSP exception occurs when using the JSTL database: According to TLD or attribute directive in tag file, attribute value does not accept any expressions, may be due to use of JSP2.0 version, while not using JS ...

  • Development of my SSH configuration database 2009-04-10

    Recently used at Struts1.x + Spring2.5 + Hibernate3.2 the development of an online examination system, a lot of feel! One of configuration are dependent on at a time when packet is not good hands, because the habit of using IDE, anything can be automatica

  • Struts2 in the internationalization of the FreeMarker configuration 2010-03-29

    The Struts2 using FreeMarker as the presentation layer is basically configured as a universal. However, developers are familiar with JSP accustomed to the use of JSP tags, while the use of FreeMarker macros indeed, although some differences between t ...

  • JSTL error According to TLD or attribute directive in tag file 2010-03-29

    Today engage in JSTL, they found a big problem, JSTL any grammar are not wrong cases, reported the following error: org.apache.jasper.JasperException: / index.jsp (42,5) According to TLD or attribute directive in tag file, attribute items does not ac ...

  • JSTL.JAVA the floating-point digital output format 2010-03-29

    As the EL expression is a floating-point operation result when (and EL expression in addition to computing the result is floating point, this and a little bit different from other languages), the web page displayed on a long list indeed indecent. The ...

  • ssh Integration Configuration 2010-03-29

    web.xml file <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/n

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.035 (s). 14 q(s)