错误:javax.servlet 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22836220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 18:13:57  来源:igfitidea点击:

ERROR : javax.servlet does not exist

javapostgresqltomcatservlets

提问by woodhead92

I have checked almost all the posts possible for the error that I'm getting. Ive edited almost all the ENVIRONMENT VARIABLESas given online. These are my environment variables :

我已经检查了几乎所有可能出现的错误信息。我已经编辑了几乎所有在线给出的环境变量。这些是我的环境变量:

ANT_HOME= C:\Ant9;C:\Tomcat7\lib\servlet-api.jar

ANT_HOME= C:\Ant9;C:\Tomcat7\lib\servlet-api.jar

CLASSPATH= C:\Program Files\Java\jdk1.6.0_24\bin;C:\Program Files\Java\jre6\bin;C:\Tomcat7\lib\servlet-api.jar;.

CLASSPATH= C:\Program Files\Java\jdk1.6.0_24\bin;C:\Program Files\Java\jre6\bin;C:\Tomcat7\lib\servlet-api.jar;。

JAVA_HOME= C:\Program Files\Java\jdk1.6.0_24

JAVA_HOME= C:\Program Files\Java\jdk1.6.0_24

PATH= C:\Program Files\Java\jdk1.6.0_24\bin

PATH= C:\Program Files\Java\jdk1.6.0_24\bin

TOMCAT_HOME= C:\Tomcat7

TOMCAT_HOME= C:\Tomcat7

C:\Tomcat7\webapps\DBConnection\WEB_INF\classes\DBConnection>javac -cp .,C:\Tomc
at7\lib\servlet-api.jar DBConnnection.java
DBConnnection.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
DBConnnection.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
DBConnnection.java:11: cannot find symbol
symbol: class HttpServlet
public class DBConnnection extends HttpServlet
                                   ^
DBConnnection.java:14: cannot find symbol
symbol  : class HttpServletRequest
location: class DBConnection.DBConnnection
  public void doGet(HttpServletRequest request, HttpServletResponse response) th
rows ServletException, IOException
                    ^
DBConnnection.java:14: cannot find symbol
symbol  : class HttpServletResponse
location: class DBConnection.DBConnnection
  public void doGet(HttpServletRequest request, HttpServletResponse response) th
rows ServletException, IOException
                                                ^
DBConnnection.java:14: cannot find symbol
symbol  : class ServletException
location: class DBConnection.DBConnnection
  public void doGet(HttpServletRequest request, HttpServletResponse response) th
rows ServletException, IOException

     ^
DBConnnection.java:53: cannot find symbol
symbol  : class EmployeeInformation
location: class DBConnection.DBConnnection
                    EmployeeInformation empInfo = new EmployeeInformation();
                    ^
DBConnnection.java:53: cannot find symbol
symbol  : class EmployeeInformation
location: class DBConnection.DBConnnection
                    EmployeeInformation empInfo = new EmployeeInformation();
                                                      ^
DBConnnection.java:13: method does not override or implement a method from a sup
ertype
  @Override
  ^
9 errors

Im really baffled as to how to proceed! Been stuck at this point!!

我真的很困惑如何继续!一直卡在这个位置!!

采纳答案by Keerthivasan

You should use ;to separate classpath entries in Windows

您应该使用;分隔 Windows 中的类路径条目

javac -cp .;C:\Tomcat7\lib\servlet-api.jar DBConnnection.java.

javac -cp .;C:\Tomcat7\lib\servlet-api.jar DBConnnection.java.

but, you used a comma ,. Change comma to semicolon

但是,您使用了逗号,。将逗号改为分号

Note : *nix family environments use colon :to seperate classpath entries

注意:*nix 系列环境使用冒号:来分隔类路径条目