Getting error while accessing the Map from Spring Controller to JSP using JSTL

后端 未结 2 1699
轮回少年
轮回少年 2021-01-15 10:46

I have a spring controller in which I am returning a Map named \"model\"; model contains some set of values but importantly also contains an ArrayList. Now I am

相关标签:
2条回答
  • 2021-01-15 11:32

    As per the stacktrace,

    java.lang.NoSuchMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
        at javax.servlet.jsp.jstl.core.LoopTagSupport.unExposeVariables(LoopTagSupport.java:587)
    

    the JSTL <c:forEach> tag is expecting the method PageContext#getELContext(). This method was introduced in JSP 2.1. This exception thus suggests that you are using JSTL 1.2, while your container doesn't support JSP 2.1 or that you have littered your runtime classpath with servletcontainer specific JSP libraries of a container which doesn't support JSP 2.1. The runtime classpath covers among others the webapp's /WEB-INF/lib folder and Java's JRE/lib and JRE/lib/ext folders .

    You should never put servletcontainer specific libraries in those folders, such as jsp-api.jar, servlet-api.jar, el-api.jar, j2ee.jar, javaee.jar, etc..etc.. Those files which you usually see in /lib folder of the servletcontainer itself. E.g. Tomcat/lib. It makes your webapp unportable to the target servletcontainer. The target servletcontainer where you're running this webapp has those libraries already. If you did this to overcome compilation errors on JSP/Servlet packages, then you should have solved it differently. See also How do I import the javax.servlet API in my Eclipse project?


    Update: as per your update, you're using Weblogic 9.2 which is a Servlet 2.4 / JSP 2.0 container. It does not support JSP 2.1 / JSTL 1.2 at all. You need to remove the JSTL 1.2 library. If I am not mistaken, Weblogic ships with JSTL 1.1 already. Otherwise you need to include it in the classpath (the /WEB-INF/lib folder) yourself. You can find a JSTL 1.1 download link in our JSTL wiki page.

    0 讨论(0)
  • 2021-01-15 11:45

    Do you have a el-api.jar in your webapp?

    Please see the following post:

    http://www.coderanch.com/t/526731/JSP/java/java-lang-NoSuchMethodError-javax-servlet

    -Kaj :)

    0 讨论(0)
提交回复
热议问题