The superclass “javax.servlet.http.HttpServlet” wa

2020-01-27 08:51发布

I have a project created by Maven integration in Eclipse. All work fine, but in the work space in all JSP files have this:

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

To the first string where place:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

When I create a basic dynamic web project and JSP in - all is fine, no errors.

14条回答
贼婆χ
2楼-- · 2020-01-27 09:11

Project → PropertiesTarget RuntimesApache Tomcat worked for me. There is no Target Runtimes under Facets (I'm on Eclipse v4.2 (Juno)).

查看更多
男人必须洒脱
3楼-- · 2020-01-27 09:14

In case of JBoss... right click on project → Build Java path → add external JAR files.

Then browse to jboss-folder → Commonlib → servlet-api.jar

. . Click OK, refresh the project, and run it...

查看更多
够拽才男人
4楼-- · 2020-01-27 09:18

Adding the Tomcat server in the server runtime will do the job:

Project PropertiesTarget Runtimes → Select your Server from the list, "JBoss Runtime" → Finish

In case of Apache you can select Apache Runtime.

Enter image description here

查看更多
做自己的国王
5楼-- · 2020-01-27 09:21

Select project → PropertiesProject FacetsTarget RuntimesVMware Server.

It worked for me.

查看更多
兄弟一词,经得起流年.
6楼-- · 2020-01-27 09:21

If you are not using Maven, just drop the javax.servlet-api.jar in your project lib folder.

查看更多
男人必须洒脱
7楼-- · 2020-01-27 09:22

Adding the Tomcat server in the server runtime will do the job:

Project properties → Java Build PathAdd LibrarySelect "Server Runtime" from the list → Next → Select "Apache Tomcat" → Finish.

查看更多
登录 后发表回答