IDEA cannot find import javax.servlet... related class package when creating servlet

First, in IDEA, when creating a servlet, when writing the following statement:

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

import javax.servlet.http.HttpSession;

 

You will be prompted that package javax.servlet and package javax.servlet.http do not exist errors

2, The reason is that the java compiler does not find the package javax.servelt.

3, the solution: copy the servlet-api.jar in the lib directory of the tomcat installation package to the lib subfile in the WEB-INF directory in the web directory of the project folder, namely 
web—>WEB -INF-lib.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326015766&siteId=291194637
Recommended