MyEclipse中,使用Maven新建web项目后,提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

问题描述:

  使用 MyEclipse + Maven 建立了一个 Javaweb工程,在编写 JSP页面 时,顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path。如下图所示:

  MyEclipse中,使用Maven新建web项目后,提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

解决方法:

  在该项目中的 pom.xml 中添加下面代码来下载servlet-api,如下所示:

    <dependencies>
        <dependency>  
            <groupId>javax.servlet</groupId>  
            <artifactId>servlet-api</artifactId>  
            <version>2.5</version>  
            <scope>provided</scope>  
        </dependency> 
    </dependencies>

  然后 项目右键 --> Maven --> Update Project 即可。