当前位置: 代码迷 >> JavaScript >> JSTL小结
  详细解决方案

JSTL小结

热度:263   发布时间:2012-07-01 13:15:00.0
JSTL总结

(一)JSTL各版本下载

?

1JSTL1.0(包含2jar文件:jstl.jarstandard.jar。这两个jar文件都存在于Standard1.0.x的发布版本中。)

下载地址:http://archive.apache.org/dist/jakarta/taglibs/standard-1.0/binaries/

最新版本是:jakarta-taglibs-standard-1.0.3.zip。解压后从lib文件夹中找到这个两个jar

2JSTL1.1(也包含2jar文件:jstl.jarstandard.jar。这两个jar文件都存在于Standard1.1.x的发布版本中。)

下载地址:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/

最新版本是:jakarta-taglibs-standard-1.1.2.zip。解压后从lib文件夹中找到这个两个jar

3JSTL1.2(只包含1jar文件:jstl-1.2.jar

??? -- JSTL 1.2 is part of the Java EE 5 platform.

下载地址:http://jstl.java.net/

(二)JSTL各版本差异

NOTE:

Standard-1.1 (JSTL 1.1) requires a JSP container that supports the Java Servlet 2.4 and JavaServer Pages 2.0 specifications. Jakarta Tomcat 5 supports the new specifications. The Standard-1.1 taglib has been tested with Tomcat 5.0.3.

Standard-1.0 (implementation of the JSTL 1.0 specification) requires a JSP container that supports the Java Servlet 2.3 and JavaServer Pages 1.2 specifications. Jakarta Tomcat 4 supports these specifications. The Standard 1.0 taglib has been tested with Tomcat 4.1.24.

?

1. JSTL1.0(不支持EL)JSTL 1.1JSTL 1.2支持的servletjsp规范都不相同,支持相应规范的tomcat的版本也有要求的。具体如下。

?web.xml中要申明相应的servlet版本。

JSTL1.2需要servlet2.5

<web-app xmlns="http://java.sun.com/xml/ns/javaee"

version="2.5"

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">

?

JSTL1.1JSP2.0需要servlet2.4

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4 " xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?? http://java.sun.com/xml/ns/j2ee/web-app_2_4 .xsd">

?

JSTL1.0JSP1.2需要servlet2.3

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.3 " xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?? http://java.sun.com/xml/ns/j2ee/web-app_2_3 .xsd">

?

2. JSTL1.0JSTL1.1uri是不一样的,但是他们的tld文件同时存在于同一个standard.jar中。解压缩下载的standard.jar,你会在/META-INF/下发现有一个c-1_0.tld,还有一个c.tld。其中c-1_0.tldJSTL1.0core标签库的tld文件,c.tldJSTL1.1core标签库的tld文件。JSTL1.1JSTL1.2uri是一样的。

?

JSTL1.0的使用方法为:

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

JSTL1.1的使用方法为:

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

JSTL1.2的使用方法为

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

?

开启EL:只有 servlet2.4 是默认支持 el表达式的。

其他的都要 JSP页面开头加入: <%@ page isELIgnored="false"%>servlet2.5默认是禁用el的,所以会出现${}现象,加入上述代码开启EL

?

以下来自互联网:

JSP2.0(Servlet 2.4)及以后(推荐用JSTL1.1及以上)用:

Java代码????

<%@taglib prefix="c" uri="http://java.sun.com/[color=red]jsp[/color]/jstl/core" %>?

?

web.xml

Java代码????

<?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/ns/j2ee/web-app_2_4.xsd" >?

?

?

Servlet2.3及以前,

Java代码????

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

?

2.4以后版本少了jsp

web.xml

Java代码????

<?xml version="1.0" encoding="UTF-8"?>??

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

<web-app>??

</web-app>?

?

?

Servlet2.3中最好用JSTL1.0,如果用JSTL1.1,请加上

Java代码????

<?xml version="1.0" encoding="UTF-8"?>??

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

<web-app>??????

? <taglib>??

<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>??

<taglib-location>/WEB-INF/c.tld</taglib-location>??

</taglib>??

</web-app>?

?

tld目录下的c.tld拷贝到/WEB-INF下。

(三)JSTL Tutorial

http://download.oracle.com/javaee/5/tutorial/doc/bnagx.html

(四)Standard Taglib(standard.jar)

http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

Standard: An Implementation of the JavaServer Pages? Standard Tag Library (JSTL)

Documentation ('doc/web' directory)

??????????? Getting Started: A quick roadmap to help you get started with this release.

??????????? Release Notes: Release history of the Standard Taglib.

Sun's JSTL web site is the official website for JSTL, providing access to the specification (the specification is a formal description of the functionality and features of the JSTL tag set), as well as lists several tutorials and books about JSTL that are available.

Examples ('examples' directory)

The standard-examples application included with this distribution demonstrates the current capabilities of JSTL, exploring idioms and usage patterns when appropriate.

Implementation of JSTL ('src' and 'conf' directories)

Every effort has been made to provide a functional, robust, and speedy implementation of JSTL. For developers, the code is commented thoroughly to help provide an understanding of design considerations and salient implementation details.

Classes in any of the subpackages of javax.servlet.jsp.jstl represent JSTL API classes. Classes under org.apache.* represent implementation classes. The implementation's package structure is organized as follows:

? org.apache.taglibs.standard

?? .tag???????? tag handlers and routines related to them

????? .common????? handlers and support routines common for RT/EL attributes

????????? .core??? core library (common)

????????? .fmt???? i18n-capable formatting tags (common)

????????? .xml???? XML manipulation library (common)

??????????? ? .sql???? ?? SQL library (common)

????? .el????????? handlers specific to expression language (EL) evaluation

????????? .core??? core library (EL)

????????? .fmt???? i18n-capable formatting tags (EL)

????????? .xml???? XML manipulation library (EL)

??????????? ? .sql???? ?? SQL library (EL)

????? .rt????????? handlers specific to rtexprvalue (rt) evaluation

????????? .core??? core library (rt)

????????? .fmt???? i18n-capable formatting tags (rt)

????????? .xml???? XML manipulation library (rt)

??????????? ? .sql???? ?? SQL library (rt)

?? .functions?? EL Functions library

?? .tei???????? TagExtraInfo classes (common to both libraries)

?? .tlv???????? TagLibraryValidator classes (and associated helpers)

?? .lang??????? expression-language support and implementation

????? .support???? ExpressionEvaluator, ExpressionEvaluatorManager

????? .jstl??????? JSTL 1.0 expression language

?? .resources?? Resources for internationalization

The javax.servlet.jsp.jstl.* tree is discussed in the JSTL specification.

Standard-1.1 Taglib News

10/25/2004?????? Standard Taglib version 1.1.2 - A minor bug fix update - is now available from the Apache Jakarta Project Mirrors.

?

07/20/2004?????? Standard Taglib version 1.1.1 - A minor bug fix update - is now available from the Apache Jakarta Project Mirrors.

?

01/30/2004??????? Standard Taglib version 1.1.0 - First official release of our implementation of JSTL 1.1 - is now available from the Apache Jakarta Project Mirrors.

?

09/25/2003??????? Standard Taglib version 1.1.0-B1 - early access (Beta 1) of our implementation of JSTL 1.1 - is now available from the Apache Jakarta Project Mirrors.

?