源码:
----c_out.jsp-----<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@ page language="java" import="java.util.*" pageEncoding="GB2312"%><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'c_out.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
    This is my JSP page. <br>
    <%
     String s="nihao";
     request.setAttribute("s",s);
    %>
    <c:out value="woainni" />
    <%
     if(10>9) {%>
     <c:out value="10>9" escapeXml="false">
    
     </c:out>
    <%}else{
    %>
     <c:out value="Error" default="hehe"/> <!--请注意:这里会产生异常-->
    <%}%>
    <c:out value="${s}" default="这里什么都没有!"/>
  </body>
</html>---------web.xml---------<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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>   
<page-encoding>GB2312</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-coda></include-coda>
</jsp-property-group>

</jsp-config>


</web-app>编译正常,运行时发生以下异常:javax.servlet.ServletException: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
org.apache.jsp.pages.c_005fout_jsp._jspService(org.apache.jsp.pages.c_005fout_jsp:136)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()Ljavax/servlet/jsp/el/VariableResolver;
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:922)
org.apache.jsp.pages.c_005fout_jsp._jspx_meth_c_out_3(org.apache.jsp.pages.c_005fout_jsp:218)
org.apache.jsp.pages.c_005fout_jsp._jspService(org.apache.jsp.pages.c_005fout_jsp:126)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)=======开发环境========
IDE:Eclipse3.1+MyEclipse4.02
WebServer:Tomcat5.5.9非常感谢你的关注和help!

解决方案 »

  1.   

    你是说不能正确输出值?那还是有输出的,输出的值是什么,你可以看看程序中什么地方对设置这些值了。应该很好找到。是在不行就把request、session、servletContext中的属性值都打出来,看看问题到底出在什么地方。
      

  2.   

    建议把整个jsp用try{}catch(Throwable t){t.printStackTrace();}包起来再试.
      

  3.   

    <%
         String s="nihao";
         request.setAttribute("s",s);
        %>
    <c:out value="${s}" default="这里什么都没有!"/>
    如果我不用EL表达式,直接赋值,就可以输出!<c:out value="nihao" default="这里什么都没有!"/>
    我想在这里使用表达式语言!可是一用表达式就输出异常!Thanks for your help!
      

  4.   

    是不是你在页面中禁用了el,你写一个最简单的el,看能不能输出.你在头部加上elEnable(具体怎么写不记得,自己查),试试
      

  5.   

    jsp页面中用EL是在jsp2.0/servlet2.4以后才能用,所以你可以修改web.xml:
    <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   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
    ,重新启动tomcat
    也可以在页面上加上<%@ page isELIgnored ="false" %>
      

  6.   

    jsp页面中用EL是在jsp2.0/servlet2.4以后才能用,所以你可以修改web.xml:
    <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   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
    ,重新启动tomcat
    也可以在页面上加上<%@ page isELIgnored ="false" %>我的回复:    这些我都试过了!
        
        可是还有这样的异常,请帮忙:
        javax.servlet.ServletException:
    javax.servlet.jsp.PageContext.getVariableResolver()    java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()    谢谢你!
      

  7.   

    你有没有把servlet.jar或者servlet-api.jar添加到classpath中?
      

  8.   

    我用的是JSTL1.1,采用JSP2.0和Servlet2.4规范,就出现如下异常:
      
           javax.servlet.ServletException:
    javax.servlet.jsp.PageContext.getVariableResolver()    java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()如果我用JSTL1.0,采用JSP2.0和Servlet2.4规范,按照你(esprit0318)的方法,就可以解析表达式了!
    真奇怪! 谢谢你的帮助!