且构网

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

IntelliJ IDEA无法解析导入javax.servlet。*;

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

servlet-api.jar是服务器的一部分(在本例中为Tomcat)。您需要在POM中声明对该jar的引用并在提供的范围内标记它(如果由于某种原因您没有使用maven),则需要将其添加到类路径中(您的Web模块中的库)项目)。

The servlet-api.jar is part of your server (Tomcat in this case). You need to either state a reference to that jar in your POM and mark it in 'provided' scope or (if you are not using maven for some reason) you need to add it to your classpath (the libraries of your web module in your project).

重新安装HD后,你的Tomcat安装程序或maven repo可能会有所不同。这似乎是一个环境问题。

The chances are perhaps that your Tomcat installation forder or maven repo is different after your HD reinstall. It seems to be like an environmental issue.