目前在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目录下有)。
本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1679924