JSTL standard.jar和jstl.jar

standard.jar是JSP 标准标签库,在1.0、1.1的版本中,和jstl.jar 一起使用,但在jstl-1.2.jar 就不再需要了。先上传两个jar,如何使用继续研究中。

[b]
JSTL versions[/b]

JSTL is available in different versions:

1.0: composed of two JAR files jstl.jar (the API) and standard.jar (the impl). Taglib URI has no /jsp in path like http://java.sun.com/jstl/core and the prototype version has the library name suffixed with _rt like http://java.sun.com/jstl/core_rt. Came along with and requires at minimum Servlet 2.3 / JSP 1.2. It is at end of life, do not use it any more.

1.1: composed of same JAR files as 1.0. Taglib URI includes /jsp in the path like http://java.sun.com/jsp/jstl/core. Came along with and requires at minimum Servlet 2.4 / JSP 2.0. Downloadable here.

1.2: composed of one JAR file jstl-1.2.jar (bundled API+impl) and has same taglib URI as 1.1. Came along with Servlet 2.5 / JSP 2.1 but works at Servlet 2.4 / JSP 2.0 as well. Downloadable here.

1.2.1: composed of two JAR files javax.servlet.jsp.jstl-api-1.2.1 (the API) and javax.servlet.jsp.jstl-1.2.1.jar (the impl) and has same taglib URI as 1.1. Came along with Servlet 3.0 / JSP 2.2 but works at Servlet 2.5 / JSP 2.1 and Servlet 2.4 / JSP 2.0 as well. Downloadable here and here.

Facelets: Facelets, the successor of JSP, has among the provided taglibs a selected subset of JSTL 1.2 core and the full set of JSTL 1.2 functions builtin. This requires a minimum of JSTL 1.2. For Facelets 1.x the XML namespace URI is http://java.sun.com/jstl/core and for Facelets 2.x the XML namespace URI is http://java.sun.com/jsp/jstl/core with (confusingly!) the /jsp part.

[b]
Installing JSTL[/b]

It's actually quite simple:

Only when your servletcontainer doesn't ship with JSTL (e.g. Tomcat), place the JAR file(s) in Webapp/WEB-INF/lib (which is covered by the default webapp's classpath, so in a bit smart IDE you don't need to do anything else).

Declare the taglib in JSP file with the right TLD URI. You can find here the TLD documentation that applies to both JSTL 1.1 and JSTL 1.2. Click the taglib of interest to get the declaration examples. For example the JSTL core taglib

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

If you're using Facelets instead of JSP, it should be declared as XML namespace instead

<html xmlns:c="http://java.sun.com/jsp/jstl/core">


You only need to ensure that you have no duplicates of older JSTL versions in the classpath (includes JRE/lib and Appserver/lib) to avoid collisions. If you have full admin-level control over the appserver, then you could also place the JAR file(s) in Appserver/lib instead of Webapp/WEB-INF/lib so that they get applied to all deployed webapps. At least do NOT extract the JAR file(s) and clutter the classpath with their contents (the loose TLD files) and/or declare the taglibs in your webapp's web.xml as some poor online tutorials suggest.

Help! The expression language (EL, those ${} things) doesn't work in my JSTL tags!

The declared servlet version in web.xml is very important to get JSTL and EL to work properly. You need to ensure that you're using a servletcontainer that supports the minimum required Servlet version for the JSTL version. Apache Tomcat 6.0 for example is a Servlet 2.5 container. You should then declare your web.xml conform to the Servlet 2.5 specification, this works for both JSTL 1.1 and 1.2:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
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"
version="2.5">
<!-- Config here. -->
</web-app>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值