Javax.servlet.jsp.JspException cannot is resolved to a type and javax.servlet.jsp.PageContext cannot be resolved to a type solution Solution

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.