Tomcat5与Tomcat6的EL冲突,JSTL的…

来源:互联网 发布:基站实测软件 ios 编辑:程序博客网 时间:2024/05/18 22:12

正在开发的程序在Tomcat6下运行得好好的,一拷贝到Tomcat5就出错了
Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: javax/el/ELException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2365)
at java.lang.Class.getDeclaredMethods(Class.java:1763)
at java.beans.Introspector$1.run(Introspector.java:1259)
at java.security.AccessController.doPrivileged(Native Method)
atjava.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1257)
atjava.beans.Introspector.getTargetMethodInfo(Introspector.java:1125)
at java.beans.Introspector.getBeanInfo(Introspector.java:383)
at java.beans.Introspector.getBeanInfo(Introspector.java:155)
at java.beans.Introspector.getBeanInfo(Introspector.java:216)
atjava.beans.Introspector.<init>(Introspector.java:364)
at java.beans.Introspector.getBeanInfo(Introspector.java:155)
atorg.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3673)
atorg.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2092)
atorg.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1573)
atorg.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
atorg.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
atorg.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
atorg.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)

这个问题应该是出在JSTL的支持上,通过查看,原来系统使用了JSTL1.2。再进一步到网上查看相关资料,发现:

The JSTL 1.2 Maintenace Release aligns with the UnifiedExpression Language (EL) that is being delivered as part of theJavaServer Pages (JSP) 2.1 specification。JSTL 1.2 is part of theJava EE 5 platform. (from http://java.sun.com/products/jsp/jstl/)

Jakarta Taglibs hosts the Standard Taglib 1.1, an implementationof the JSP Standard Tag Library (JSTL), version 1.1, which wasdeveloped under the Java Community Process.
NOTE: Standard-1.1 (JSTL 1.1) requires a JSP container thatsupports the Java Servlet 2.4 and JavaServer Pages 2.0specifications. 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 andJavaServer Pages 1.2 specifications. Jakarta Tomcat 4 supportsthese specifications. The Standard 1.0 taglib has been tested withTomcat 4.1.24. (from http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html)

Tomcat6 实现了 servlet 2.5 和JSP2.1的规范,可以支持JSTL1.2;而Tomcat5实现了servlet 2.4 和JSP2.0的规范,只能支持JSTL1.1

所以,只要使用JSTL1.1(standard-1.1.jar和jstl-1.1.jar)替换JSTL1.2(jstl-1.2.jar)即可在Tomcat5下正常运行!另外,web.xml必须指定使用servlet2.4 和JSP2.0的规范:
<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/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

原创粉丝点击