`
oldbig
  • 浏览: 75210 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JSTL标签库的版本变迁及最新发展

阅读更多
从来没认为这是个问题,不过最近发现网上关于这方面的资料比较乱,现将自己的了解整理在此,以备查阅。
 
开发团队经常使用jstl标签库,开始也没在意,大家都是简单引入jstl.jar和standard.jar,后来发现这两个包也有版本差别,各项目小组用的不同,在jsp中定义也有差别,还会引起冲突和代码不兼容。于是想在网上找个最新的包,使用一种最官方推荐的用法把团队的开发规范一下。本以为这是个极简单的活,不料却也费了一番功夫。
 
首先,关于JSTL之前的各版本及用法,请见这篇文章:
其中关于1.2版本,只有一个jar包,打开看一下。其实是把之前两个jar包(jstl.jar,接口定义包;standard.jar实现包)合二为一了,但这个包的出处却不详,怀疑是谁为了使用便自己打成的包。
关于JSTL标准及接口定义,其最新版应该就是1.2版了,这个大约是2011年推出的。
 
我这里重点整理一下关于JSTL实现的最新进展。在2009年之前,Jakarta Taglib项目组提供了JSTL的各版本的实现jar包(也就是常见的jstl.jar和standard.jar),此后taglib项目则被转到tomcat小组的旗下,具体见下方
Starting in 2000, Jakarta hosted the Jakarta Taglibs project, a large collection of JSP Tag Libraries. They ranged from simple utility libraries and UI libraries, to Dreamweaver extensions and an implementation of the JSP Standard Tag Library (JSTL) specification.

With the advent of JSTL, the core features of many of the libraries had been standardized and the need for these libraries diminished. As such, much of the Taglibs codebase moved into maintenance mode.
In 2008 and 2009, the majority of these libraries were deprecated and have now been retired. The remaining work has moved over to the Tomcat Taglibs project - namely the following taglibs:
- Standard - The implementations of the various JSTL specifications
- RDC - Reusable Dialog Components Taglib
In 2014 the RDC Taglib was retired from the Tomcat Taglibs project.
 
大概翻译下:
从2000年开始,Jakarta开发管理着Jakarta标签库项目,这是一个JSP标签库的大集合。这个项目包括了从简单的应用库到UI库,还包括Dreamweaver扩展以及对JSP标准标签库定义(JSTL)的实现。
随着JSTL的出现,包含在这个项目中很多库特征已被标准化,并且对这些库的需求也在减少。 相应地,很多标签库的基础代码已转为维护状态(不再更新)。
2008到2009年,这些库中的主要部分都不推荐使用,到现在已经被废弃了。其余的工作被挪到了Tomcat Taglibs项目----也就是下列的标签库:
标准--各种JSTL定义的实现。
 
-------------------------------------------------------------------------------------------------
于是转到tomcat的taglib项目页面:http://tomcat.apache.org/taglibs/
2015/02/20 [StandardThe Apache Standard Taglib 1.2.3, a minor bugfix version, has been released.
2014/01/02 [StandardThe Apache Standard Taglib 1.2.1, an implementation of JSTL 1.2, has been released.
2009/06/07 [ALL] The Standard and RDC Taglibs have moved over to Tomcat. All other taglibs back at Jakarta have been deprecated.
 
好家伙,2009年接手这个项目,到2014年才更新一版,最新版本是2015年2月份。
可以看到最新的版本是Standard1.2.3,实现的JSTL版本是JSTL1.2。系统要求是Servlet 2.5, JavaServer Pages 2.1.
 到下载页面下载到的却是最新的1.2.5版
taglibs-standard-spec-1.2.5.jar(相当于之前的jstl.jar,属于接口定义类)
taglibs-standard-impl-1.2.5.jar jar(相当于之前的standard.jar,属于实现类)
 
不过查看其中的c.tld文件,标注的版本号就是
<description>JSTL 1.2 core library</description>
<display-name>JSTL core</display-name>
<tlib-version>1.2</tlib-version>
也就是说,接口规范的版本还是1.2,1.2.5只是实现的版本罢了。
 
JSTL的另一个实现,是在oracle官网上查到的由glassfish提供的,其最新版本也是1.2,而且看日期还是2011年的版本。
----------------------------------------------------------
关于使用方法,在最新版的页面上有一个readme,基本把问题说清了:
LIBRARY DEPENDENCIES
 
This version of the Standard Tag Library has the following runtime
dependencies:
 
   1. Dependencies provided by a JSP 2.1 container:
      - Java 1.5 or later
      - Servlet 2.5 or later
      - JSP 2.1 or later
 
   2. Additional dependencies
      - The XML tag library requires Apache Xalan 2.7.1 or later
 
---
Apache Xalan 2.7.1
 
To address performance issues with XSLT processing, this version relies on
implementation specific functionality from Apache Xalan. The following
libraries should be included in the classpath for your application:
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar
 
---------------------------------------------------------------------------
ADD DEPENDENCIES TO A WEB APPLICATION
 
To use this distribution with your own web applications, add the following JAR
files to the '/WEB-INF/lib' directory of your application:
   - taglibs-standard-spec-1.2.5.jar
   - taglibs-standard-impl-1.2.5.jar
   - taglibs-standard-jstlel-1.2.5.jar
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar
 
If you do not use JSTL 1.0 tags then the "taglibs-standard-jstlel" JAR may be
omitted. If you do not use the XML library, then the Apache Xalan dependencies
may also be omitted.
 
If you build you application with Maven, add the following dependencies to
your pom.xml file:
 
    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-spec</artifactId>
      <version>1.2.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-impl</artifactId>
      <version>1.2.5</version>
    </dependency>
 
---------------------------------------------------------------------------
USING JSTL TAGS FROM A JSP
 
The JSTL tag library can be imported into your pages with the following directives:
 
  CORE LIBRARY
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 
  XML LIBRARY
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
 
  FMT LIBRARY
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
  SQL LIBRARY
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
 
  FUNCTIONS LIBRARY

 

    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics