我从spring控制器返回数据如下:
HashMap hm = new HashMap();
hm.put("totalPage", pageQuery.count());
ArrayList al = new ArrayList();
while(iterator.hasNext()){
Vertex v = iterator.next();
MyPageList myPageList = new MyPageList();
myPageList.setPageName(....);
al.add(myPageList);
}
hm.put("pages", al);
...
...
HashMap hm2=new HashMap();
hm2.put("mydata",hm);
return hm2;
在jsp端如果我使用${mydata['totalPage']}
,当我尝试迭代pages
时,它会打印值bu:
<c:forEach items="${mydata['pages']}" var="v">
</c:forEach>
它显示以下异常:
javax.servlet.ServletException: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
如何显示pages
值
这是我的POM文件
http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT; 4.0.0
<groupId>com.xyz</groupId>
<artifactId>abcde</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>hello world</name>
<properties>
<spring.version>3.2.4.RELEASE</spring.version>
</properties>
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- spring security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<!-- javax mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mailapi</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.0</version>
</dependency>
<!-- Cassandra dependency -->
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-thrift</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-clientutil</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.0.0-rc2</version>
</dependency>
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<!-- Titan dependency -->
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-core</artifactId>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-cassandra</artifactId>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>com.thinkaurelius.titan</groupId>
<artifactId>titan-all</artifactId>
<version>0.4.2</version>
</dependency>
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>SpringMVC</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:1)
java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
方法javax.servlet.jsp.PageContext.getELContext()
是在JSP 2.1中引入的。 AbstractMethodError
基本上意味着运行时类路径包含与JSP 2.1兼容的API,但是包含旧版本的实现,例如JSP 2.0,1.2等。
通常,JSP API和实现都是已经由您部署Web应用程序的目标servletcontainer提供,例如Tomcat。通常,您不需要乱用其库或类路径。
此异常意味着您这样做了。此异常表明您有一些不明原因在webapp的运行时类路径中放置了较新版本的JSP API或较旧的版本化JSP实现,很可能是webapp的/WEB-INF/lib
中的JAR文件的风格。这就是许多初学者在他们的IDE项目中遇到编译错误时错误地做了什么,并且根本不了解IDE项目的“Targeted runtime”设置实际意味着什么。
您应该从不将任意下载的特定于servlet容器的JAR文件放在您的webapp /WEB-INF/lib
中,该文件最初源自与目标servletcontainer完全不同的make / version的servlet容器。它会使您的webapp与您实际要部署到的目标servletcontainer不兼容。相反,您应该设置/修复“Targeted runtime”设置,让IDE指出您要部署到的目标servletcontainer。
答案 1 :(得分:0)
首先,感谢@BalusC的回答;我从中学到了东西。
当您使用JSTL1.2时,可能是容器版本与JSTL版本不匹配:
答案:https://stackoverflow.com/a/542454/2906290
来自http://www.coderanch.com/how-to/java/JstlTagLibDefinitions:
JSTL 1.2 由两个文件组成(jstl-impl-1.2.jar和jstl-api-1.2.jar)(...)应该用于JSP 2.1容器< / strong>例如Tomcat 6.
如果情况并非如此,这个案子可能会给出一个提示,因为他得到了同样的错误,但是我不确定他是否对他的方法是正确的,因为我不确定他是否真的修改了版本,或者为什么他无法降级JSTL或升级容器: https://stackoverflow.com/a/15259704/2906290