简体   繁体   English

Tomcat 上不存在包 javax.servlet

[英]package javax.servlet does not exist on Tomcat

I am writing JApplet in Netbeans.我正在用 Netbeans 编写 JApplet。 My applet is working, so I decide to add servlet because I want to have log in/out.我的小程序正在运行,所以我决定添加 servlet,因为我想登录/注销。 When I added servlet to my project as follows:当我将 servlet 添加到我的项目时,如下所示:

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

I had the following errors:我有以下错误:

error: package javax.servlet does not exist 
import javax.servlet.ServletException;
error: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;

Apache Tomcat is working. Apache Tomcat 正在运行。

Add servlet jar to the classpath in your IDE. servlet jar添加到IDE中的类路径。 Your webcontainer will provide it at runtime. 您的Web容器将在运行时提供它。 You don't have to bundle it in your WAR 您不必将其捆绑在WAR中

I found this solution here我在这里找到了这个解决方案

Under Libraries Folder in the Project Window, Right-click and "Add Library...", then choose Java EE web 8 API在项目窗口中的库文件夹下,右键单击并“添加库...”,然后选择 Java EE web 8 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM