一、前言
JSTL(JSP Standard Tag Library,JSP标准标签库)是一个不断完善的开放源代码的JSP标签库,是由apache的jakarta小组来维护的。然而jakarta有很多子项目如Tomcat、Lucene升级为Apache子项目,当前Jakarta无剩余的子项目,Jakarta项目于2011年12月21日退役。
我需要利用Maven构建项目,此时需要使用到JSTL,但是我看到网上的一些教程,都是复制jar包到编译路径下。而这些jar包我却在Maven仓库中查不到,很是郁闷,而且查到JSTL的POM配置有些怪异,因此在这里进行整理一下。
官网:http://tomcat.apache.org/taglibs/
JSTL与Servlet&JSP版本对照图(官网)
- JSTL 1.0&1.1 官网下载地址:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/
- JSTL 1.2 官网下载地址:http://tomcat.apache.org/download-taglibs.cgi
分析:我发现1.0与1.1没有在Maven仓库中存在,而且其使用方式都是将jstl.jar与standard.jar添加到编译路径下,并将tld文件夹中的文件(或者包含文件夹)复制到/WEB-INF,然后配置web.xml文件;而1.2就不一样了。再往下我是对各个版本README文件进行分析,如果没兴趣可以直接看第二段落。
1.1 JSTL 1.0
README文件(部分)
The following two files are standalone web applications (WARs) that are
designed to work out of the box in order to help you learn JSTL:
standard-doc.war Documentation
standard-examples.war Simple examples of JSTL tags
To use this distribution with your own web applications, simply copy the JAR
files in the 'lib' directory to your application's WEB-INF/lib directory.
Then, import JSTL into your pages with the following directives:
CORE LIBRARY
EL: <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
RT: <%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt" %>
XML LIBRARY
EL: <%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
RT: <%@ taglib prefix="x_rt" uri="http://java.sun.com/jstl/xml_rt" %>
FMT LIBRARY
EL: <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
RT: <%@ taglib prefix="fmt_rt" uri="http://java.sun.com/jstl/fmt_rt" %>
SQL LIBRARY
EL: <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
RT: <%@ taglib prefix="sql_rt" uri="http://java.sun.com/jstl/sql_rt" %>
COMPATIBILITY
前面讲的是这两个*.war文件都是一个示例项目,可以帮助我们学习JSTL。紧随其后就是使用方式,