使用JSTL中的一个莫名其妙的问题以及解决

昨天是我初次使用JSTL,因为我是用Eclipse开发的,就按照网上的一篇入门文章做下去:

1。下载并解压了Jakarta jstl 1.1.1.

2. 将解压后的lib目录下的两个jar文件拷贝到tomcat 下的自己的应用下的WEB-INF/lib目录下

3。将解压后的tld目录下的tld文件拷贝到到tomcat 下的自己的应用下的WEB-INF/目录下

4.修改web.xml为以下内容:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app  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/j2ee web-app_2_4.xsd"  
      version="2.4">

 

 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

 <error-page>
  <error-code>404</error-code>
  <location>/error.jsp</location>
 </error-page>
 <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
    <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
    <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
    <taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
    <taglib-location>/WEB-INF/sql-rt.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
    <taglib-location>/WEB-INF/x-rt.tld</taglib-location>
</taglib>

</web-app>

然后,我把例子jsp加上去(count.jsp):

然后,我把例子jsp加上去(count.jsp):

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Count to 10 Example (using JSTL)</title>
  </head>

  <body>
    <c:forEach var="i" begin="1" end="10" step="1">
      <c:out value="${i}" />

      <br />
    </c:forEach>
  </body>
</html>

然后启动tomcat,开始测试,这时莫名其妙的错误出现了:

 

StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
 at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:941)
 at org.apache.jsp.teslib3_jsp._jspx_meth_c_out_0(teslib3_jsp.java:143)
 at org.apache.jsp.teslib3_jsp._jspx_meth_c_forEach_0(teslib3_jsp.java:113)
 at org.apache.jsp.teslib3_jsp._jspService(teslib3_jsp.java:65)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

....

百思不得其解,查文档有的说是compiler 不对,或者lib没有加全,我反复检查均未发现错误(java 环境:jsdk1.4.2.7)

StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
 at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:941)
 at org.apache.jsp.teslib3_jsp._jspx_meth_c_out_0(teslib3_jsp.java:143)
 at org.apache.jsp.teslib3_jsp._jspx_meth_c_forEach_0(teslib3_jsp.java:113)
 at org.apache.jsp.teslib3_jsp._jspService(teslib3_jsp.java:65)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

....

百思不得其解,查文档有的说是compiler 不对,或者lib没有加全,我反复检查均未发现错误(java 环境:jsdk1.4.2.7)

 在反复试验之后,我把web.xml中web-app的xmlns 和xsi属性去掉(红色部分),结果ok,但具体原因一直也不清楚,希望高手能说明。

阅读更多
个人分类: Jsp&servlet
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

使用JSTL中的一个莫名其妙的问题以及解决

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭