1. 程式人生 > >報錯資訊:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

報錯資訊:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

報錯資訊:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

今天建立了一個Javaweb工程,並在eclipse中配置了Web容器Tomcat。JSP頁面頂端出現“紅色”的報錯資訊:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path。原來Javaweb工程類中沒有新增Tomcat執行時相關類導致。

解決方式:右擊web工程-》屬性或Build Path-》Java Build Path->Libraries-> Add Libray…->Server Runtime -》Tomcat Server。
注意:
按以上方法操作時,若開啟Server Runtime後一片空白,需要設定Apache伺服器。設定方法為:window->Preferences->Server->Runtime Environment -> add –> 選擇Apache的版本後點Next,再填入你apache伺服器軟體的安裝(解壓後)地址。