源码:
----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!
解决方案 »
- 文件更名。
- [在线解决]空指针问题
- TOMCAT 5.5乱码问题
- 为什么struts2-core-2.1.6.jar 需要和 commons-fileupload-1.2.1.jar同时使用
- 如何保证同一用户名不能够登录两次,怎么检测阿,给出简单代码成功实现的送3000分
- jsp群,欢迎大家加入
- 请教各位:session.setAttribute方法与session.putValue方法的区别
- 急! 问一个问题,在先等。望大虾指教
- 一个简单问题
- struts2+poi导出Excel,没有弹出导出下载的问题
- 我知道这个问题很低级,但是我给的分多啊,跪求大哥们帮忙,20分必给
- 新手的难题(望高手给予帮助)
String s="nihao";
request.setAttribute("s",s);
%>
<c:out value="${s}" default="这里什么都没有!"/>
如果我不用EL表达式,直接赋值,就可以输出!<c:out value="nihao" default="这里什么都没有!"/>
我想在这里使用表达式语言!可是一用表达式就输出异常!Thanks for your help!
<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" %>
<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() 谢谢你!
javax.servlet.ServletException:
javax.servlet.jsp.PageContext.getVariableResolver() java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getVariableResolver()如果我用JSTL1.0,采用JSP2.0和Servlet2.4规范,按照你(esprit0318)的方法,就可以解析表达式了!
真奇怪! 谢谢你的帮助!