java - Cannot resolve symbol 'HttpServletRequest'
仅有的幸福
仅有的幸福 2017-06-12 09:19:29
0
4
1764

This project was taken from the online exam https://github.com/Eliteteams/q...

But when IDEA is compiled, an error occurs: Cannot resolve symbol 'HttpServletRequest''HttpServletResponse' 'Cookie'
I have these three jars. The strange thing is that when my project runs, the correct page pops up. What is wrong with this? Already?

仅有的幸福
仅有的幸福

reply all(4)
代言

Add this sentence to pom.xml

<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>

Setting scope to provided means that the running environment has been provided and is only used for compilation and will not be packaged.
It is not recommended to put the servlet on the classpath, after all, different projects may require different versions.


Additional sentence: Please select the servlet-api version according to the project's web.xml, or select a new servlet-api version to modify the header of web.xml

世界只因有你

This is a maven project, there is no need to manually import packages. Right click on the project MAVEN->Update Project

阿神

The compilation environment does not have javax.servlet-api.jar

The operating environment has this

Add javax.servlet-api.jar

某草草

Add a reference to tomcat, this is the easiest way

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template