The method getJspApplicationContext(ServletContext) is undefined for the type Js

 

rg.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 23 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
        org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
        org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
        org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

 上网搜,发现不少人有这个问题,但都没有解决办法。后来想到可能和tomcat6有关,因为我在工程的lib中添加了很多包(一堆什么Spring

依赖),所以把他们一删JSP就不抛异常了。我估计是,工程中和tomcat6 lib中重复的包在加载时是先被加载(也就是tomcat6中相同的包没
有被加载),而工程中的包版本要比tomcat6中的低,造成上面的异常。我对照着tomcat中包,发现工程中出现诸如catalina.jar、jsp-api.jar
、servlet-api.jar等这样的重复包,把它们从工程中删了就应该行了(对于上面的异常,原因应该是包jsp-api.jar)。看来不是什么包都可
以一股脑往工程里加阿

也有可能多了这两个jar
javax.servlet.jar 、javax.servlet.jsp

 

你可能感兴趣的:(The method getJspApplicationContext(ServletContext) is undefined for the type Js)