"The superclass " javax.servlet.http.HttpServlet " was not found on the Java Build Path"目标运行时的集合无法解析



当我在Eclipse Neon中创建JSP页面时,出现了以下错误消息:

"The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path"

当我创建一个Servlet时,出现以下错误消息:

"The import javax.faces cannot be resolved"

对于"相同"问题的其他答案说有一个共同的根源:目标运行时未在项目属性中选择。据此,我选择了Glassfish 4服务器。我可以在Java资源库Glassfish库中看到servlet-api.jar。servlet错误消息消失了,但是JSP错误消息仍然存在。我怎么能让它也消失呢?

在配置POM.xml中添加以下依赖项,这样错误就被纠正了

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
</dependencies>

OK。我重新加载了项目,错误信息消失了。

相关内容

最新更新