天天看點

Eclipse javax.servlet.jsp.PageContext cannot be resolved to a type 錯誤解決辦法

目前在jsp頁面form action中使用${pagecontext.request.contextpath }/servlet的寫法,但是一直提示有錯誤,錯誤如下:javax.servlet.jsp.pagecontext cannot be resolved to a type

網上解答過說要缺少jsp-api.jar,導入這個包之後不報錯了,但是程式啟動通路這個頁面的時候出現如下錯誤:

org.apache.jasper.jasperexception: unable to read tld "meta-inf/c.tld" from jar file "file:/c:/users/jason/.m2/repository/javax/servlet/jstl/1.2/jstl-1.2.jar": org.apache.jasper.jasperexception: failed to load or instantiate taglibraryvalidator class: org.apache.taglibs.standard.tlv.jstlcoretlvorg.apache.jasper.compiler.defaulterrorhandler.jsperror(defaulterrorhandler.java:51)org.apache.jasper.compiler.errordispatcher.dispatch(errordispatcher.java:409)org.apache.jasper.compiler.errordispatcher.jsperror(errordispatcher.java:181)org.apache.jasper.compiler.taglibraryinfoimpl.<init>(taglibraryinfoimpl.java:182)org.apache.jasper.compiler.parser.parsetaglibdirective(parser.java:386)org.apache.jasper.compiler.parser.parsedirective(parser.java:449)org.apache.jasper.compiler.parser.parseelements(parser.java:1396)org.apache.jasper.compiler.parser.parse(parser.java:130)org.apache.jasper.compiler.parsercontroller.doparse(parsercontroller.java:255)org.apache.jasper.compiler.parsercontroller.parse(parsercontroller.java:103)org.apache.jasper.compiler.compiler.generatejava(compiler.java:185)org.apache.jasper.compiler.compiler.compile(compiler.java:347)org.apache.jasper.compiler.compiler.compile(compiler.java:327)org.apache.jasper.compiler.compiler.compile(compiler.java:314)org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:592)org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:317)org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:313)org.apache.jasper.servlet.jspservlet.service(jspservlet.java:260)javax.servlet.http.httpservlet.service(httpservlet.java:717)acl.demo.servlet.filter.securityfilter.dofilter(securityfilter.java:50)

網上說需要把jsp-api.jar去掉。。這我就不會了。這不是互相沖突了麼?

經過再三試驗,解決方法如下:

不要 直接将jsp-api.jar拷貝到lib目錄下,而是通過外部jar包引用。

項目 右鍵->properties->libraries->add external jars-

選擇 外部的jsp-api.jar(tomcat6的lib目錄下有)。

Eclipse javax.servlet.jsp.PageContext cannot be resolved to a type 錯誤解決辦法

繼續閱讀