javax.servlet.ServletException cannot be resolved to a type in spring web app [duplicate] javax.servlet.ServletException cannot be resolved to a type in spring web app [duplicate] spring spring

javax.servlet.ServletException cannot be resolved to a type in spring web app [duplicate]


I guess this may work, in Eclipse select your project → then click on project menu bar on top → goto to properties → click on Targeted Runtimes → now you must select a check box next to the server you are using to run current project → click Apply → then click OK button. That's it, give a try.


It seems to me that eclipse doesn't recognize the java ee web api (servlets, el, and so on). If you're using maven and don't want to configure eclipse with a specified server runtime, put the dependecy below in your web project pom:

<dependency>      <groupId>javax</groupId>        <artifactId>javaee-web-api</artifactId>        <version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->    <scope>provided</scope></dependency>


import javax.servlet

STEP 1

Go to properties of your project ( with Alt+Enter or righ-click )

STEP 2

check on Apache Tomcat v7.0 under Targeted Runtime and it works.

source: https://stackoverflow.com/a/9287149