jstl各版本、el表达式关系、setvlet版本

来源:互联网 发布:浙师大行知学院好不好 编辑:程序博客网 时间:2024/06/05 09:25

jstl1.0不支持el表达式,假如使用的版本为jstl1.0,则在使用在<c:out>标签中使用了EL表达式的时候会报错:

原文为:

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

jstl1.0确实是不支持EL的,但是它的tld文件又存在于1.1的jar包中。


解压standard-1.1.2.jar中在META-INF文件夹中会看到:c.tld、c-1_0.tld

c.tld:代表jstl版本为1.1

c-1_0.tld:代表jstl版本为1.0


1. jstl 1.0和1.1支持的servlet,jsp规范都不相同,支持相应规范的tomcat的版本也有要求的。具体如下。

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.

 

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

JSTL1.1和JSP2.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.0和JSP1.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">

 

3. JSTL1.0和JSTL1.1的uri是不一样的,但是他们的tld文件同时存在于同一个standard.jar中。

解压缩下载的standard.jar,你会在/META-INF/下发现有一个c-1_0.tld,还有一个c.tld。

其中c-1_0.tld是JSTL1.0的core标签库的tld文件,c.tld是JSTL1.1的core标签库的tld文件。

用文本软件打开两个文件就会找到具体的uri。

 

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


也可以把c-1_0.tld或者c.tld 复制到WEB-INF下面,在jsp中引用即可:例如<%@ taglib uri="/WEB-INF/tag/c.tld" prefix="c" %>


servlet和tomcat版本对应关系:

Servlet SpecJSP SpecEL SpecWebSocket SpecJASPIC SpecApache Tomcat versionActual release revisionSupported Java Versions4.0TBD (2.4?)TBD (3.1?)TBD (1.2?)1.19.0.x9.0.0.M9 (alpha)8 and later3.12.33.01.11.18.5.x8.5.47 and later3.12.33.01.1N/A8.0.x (superseded)8.0.35 (superseded)7 and later3.02.22.21.1N/A7.0.x7.0.706 and later
(7 and later for WebSocket)2.52.12.1N/AN/A6.0.x6.0.455 and later2.42.0N/AN/AN/A5.5.x (archived)5.5.36 (archived)1.4 and later2.31.2N/AN/AN/A4.1.x (archived)4.1.40 (archived)1.3 and later2.21.1N/AN/AN/A3.3.x (archived)3.3.2 (archived)1.1 and later