IDEA Import Servlet Package Error [How to Solve]

When we use idea to import packages related to servlets, we sometimes encounter errors, which leads to the problem that servlets cannot recognize. In fact, the reason for the problem is very simple, that is, we can’t find packages related to servlets in JDK

1. Find the installation directory of Tomcat, here is C:\Program Files\Apache Software Foundation\Tomcat 8.5\lib (Note: not everyone’s directory is this, need to be based on the actual situation of your computer’s installation directory), find the Servlet-api.jar This file, copy it

2. then go to the JDK installation directory: C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext, find the ext folder, and then copy the Servlet-api.jar file just copied to this folder

3. Back to the idea, the problem is solved, if the idea is still reporting errors, restart the idea refresh

Read More: