Today I pull a project from the code cloud, is a MAVEN project, free to do their own research, found just pulled down, the project has an error, I see is httpservletrequest cannot be resolved to a type, It should be that the servlet's jar package is less, and the dependency of this servlet is added directly to the pom.xml, and this dependent domain scope is changed to provided:
1 <Dependency>2 <groupId>Javax.servlet</groupId>3 <Artifactid>Javax.servlet-api</Artifactid>4 <version>${servlet.version}</version>5 <Scope>Provided</Scope>6 </Dependency>
The error was found to be two errors on the header, both of which were caused by the jar package without the JSP, and I made a decision to add a dependency:
1 <Dependency>2 <groupId>Javax.servlet</groupId>3 <Artifactid>Jsp-api</Artifactid>4 <version>2.0</version>5 <Scope>Provided</Scope>6 </Dependency>
This will not be an error, the project started normally, the first time I this JSP-API domain range is not set to provided, start the project on the error
The report is:
1 Failed to start component [Standardengine[tomcat]. Standardhost[localhost]. STANDARDCONTEXT[/MYBATISPLUS-SPRING-MVC]]
And then I changed the scope of the JSP-API to OK, and here's why the two dependent scopes are set to provided because I'm using a maven built-in Tomcat plug-in that launches the project, and Tomcat itself
With these two jar packages, if you set the default, the two jar packages will be packed in, causing duplicates and conflicts with Tomcat's own.
We'll see.
Of course, if you're using Maven's built-in plugin jetty, you don't have to set this field range!
Workaround Two:
Select your project, right-click Build path-"Config build Path". ->libraries->add External JARS.
Then choose Tomcat on your machine and choose the Jsp-api.jar inside it.
And then all the way to be sure.
If there is a wrong place, please correct me!
Javax.servlet.jsp.JspException cannot is resolved to a type and javax.servlet.jsp.PageContext cannot be resolved to a type solution Solution