日期:2014-05-16  浏览次数:20352 次

jstl的错误总结与解决方法(与tomcat版本相关)

jstl标签竟然还与tomcat的版本有关。
一会报错:
java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
这个是你用的tomcat版本低,而jstl标签的版本高了。(我用的tomcat5.5,jstl1.2)
google一下,说是什么web.xml版本为2.4要改为2.3,还需要添加一个c.tld的引用。
修改后继续错:
The absolute uri:?
http://java.sun.com/jsp/jstl/core?cannot be resolved in either web.xml or the jar files deployed with this application


?? 这个是你的<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>,uri路径写错了,是jstl1.1版本一下的去standard.jar文件的META-INF中的c.tld中看uri路径是否多写了jsp(如:http://java.sun.com/jstl/core)。


不断的报错:
java.lang.NoClassDefFoundError: org/apache/taglibs/standard/tag/rt/core/ForEachTag
修改后仍然报错:
java.lang.NoClassDefFoundError: javax/el/ValueExpression

按照网上所说,更换为jstl1.0.1.jar和standard1.0.1.jar,依旧报错:

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


一个上午加上一小半下午时间就在这些错误中纠缠过去了,这错误真是层出不穷,连连不断啊、最后一位大神的博客被我发现,终于解决问题,因为tomcat的版本与jstl以及servlet还需要兼容的啊。

servlet/jsp???????? tomcat
?2.5/2.1??????????? ?6.0.18
?2.4/2.0??????????? ?5.5.27
?2.3/1.2???????????? 4.1.39
?2.2/1.1???????????? ?3.3.2(archived)
-----------------------------------------------------------
servlet?????? jsp???? ?jstl???? javaee
? 2.5????????? 2.1????? 1.2?????? 5.0
? 2.4????????? 2.0?????? 1.1????? 1.4
? 2.3????????? 1.2???????1.0????? 1.2
??
??
小解释一下,可能大家伙都知道了,传说中的servlet版本可以在web.xml中看到。
如我的tomcat5.5:

Xml代码??收藏代码
  1. <span?style="font-size:?medium;"><?xml?version="1.0"?