Java编程中出现javax.servlet.*类不存在怎么解决
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java编程中出现javax.servlet.*类不存在怎么解决相关的知识,希望对你有一定的参考价值。
首先说明下,我现在的程序不能用Eclipse和NetBeans等不能编译的软件,因为我要的不是程序的运行结果,而是程序编译时生成的.class文件。我所用的是JCreator,编译时提示软件包javax.servlet不存在, 另外我的环境变量也配置了,如果有什么补充的地方或者额外要导入的包,请说明下,最好能附上包的下载地址,麻烦了
参考技术A 这个servlet包不在JDK下,这个包可以从tomcat的目录下找到,如果没有tomcat,你可以去网上下载一个tomcat,目前最新版本好像是tomcat6.0,虽然不是必须的,但tomcat是编译servlet和jsp等程序最方便的服务器,而servlet-api.jar就在tomcat6.0/lib下。下载以后,记住还要把这个jar驱动器加载到你的JCreator里。HTTP Status 500 - javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/
我在项目中导入了jar,还是不能使用EL表达式,一运行就出现了下面的额错误:
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTag org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170) org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316) org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1370) org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1116) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) javax.servlet.http.HttpServlet.service(HttpServlet.java:728) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
在Maven的pom.xml中加入下面的依赖:
<dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-compat</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-impl</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-spec</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-jstlel</artifactId> <version>1.2.5</version> <scope>provided</scope> </dependency>
就不会报错了
以上是关于Java编程中出现javax.servlet.*类不存在怎么解决的主要内容,如果未能解决你的问题,请参考以下文章
IntelliJ IDEA 出现" java: 程序包javax.servlet不存在 java: 程序包javax.servlet.annotation"等错误
web项目jsp出现The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path错误
Java Web报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build