Tag Archives: Javax.napkin

Using idea and maven, there is an error: (4, 21) Java: there is no problem with the package javax.servlet

Problem description

Baidu’s many solutions are hard to make, too desperate. (fall)

You must find out the error information and your own use scenario to search, so as to find the correct solution

For example, I use Maven to create a normal Java Web project. Manually added webapp items.

As shown in the error message, it is really the problem that the package javax. Servlet does not exist. But all my bags came in, and there was no error, as shown in the figure below

Then I played with Maven’s clean and compile and idea’s cache clearing, which were useless. Of course, it’s not what other blogs say about setting environment variables and manually copying the package to Tomcat.

solve

The problem is indeed the lack of servlet package, but it is not in the compiled file. The following figure shows the directory structure that should be generated normally

If the idea is the publishing method of the set Project Name: War expanded , the war package will be generated in the target folder

If there is no javax.servlet in the Lib directory of the war package, check it as follows:

1、< packaging> war set packaging method (jar package by default)

2. Manually added webapp projects have such problems

Summary: pay attention to whether there are missing packages in the compiled file. The problem must be found with the use scenario.