且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

导入javax.servlet无法解析

更新时间:2022-06-26 07:52:24

您需要将Servlet API添加到您的类路径中。在Tomcat 6.0中,这是在Tomcat的 lib 文件夹中的一个名为 servlet-api.jar 的JAR。您可以将该JAR的引用添加到项目的类路径中,也可以将JAR的副本放在Eclipse项目中,并将其添加到该路径中。

You need to add the Servlet API to your classpath. In Tomcat 6.0, this is in a JAR called servlet-api.jar in Tomcat's lib folder. You can either add a reference to that JAR to the project's classpath, or put a copy of the JAR in your Eclipse project and add it to the classpath from there.

如果你想将JAR放在Tomcat的 lib 文件夹中:

If you want to leave the JAR in Tomcat's lib folder:


  • 右键单击项目,点击属性

  • 选择 Java构建路径

  • 点击添加外部JAR ...

  • 浏览找到 servlet-api.jar 并选择它。

  • 单击确定更新构建路径。

  • Right-click the project, click Properties.
  • Choose Java Build Path.
  • Click Add External JARs...
  • Browse to find servlet-api.jar and select it.
  • Click OK to update the build path.

或者,如果您复制JAR进入您的项目:

Or, if you copy the JAR into your project:


  • 右键单击项目,单击属性

  • 选择 Java Build Path

  • 点击添加JAR ...

  • servlet-api.jar ,然后选择。
  • 点击确定更新构建路径/ li>
  • Right-click the project, click Properties.
  • Choose Java Build Path.
  • Click Add JARs...
  • Find servlet-api.jar in your project and select it.
  • Click OK to update the build path.