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

Spring Tool Suite: 報錯信息The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
好久不寫Jsp,今天建立了一個Javaweb工程,並在eclipse中配置了Web容器Tomcat。原本開心的新建jsp頁面,添加一個簡單的Java類。可是,JSP頁面頂端出現“紅色”的報錯信息:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path。原來Javaweb工程類中沒有添加Tomcat運行時相關類導致。
下面是具體的解決方法:
1、右擊web工程-》屬性或Build Path-》Java Build Path->Libraries-> Add Libray…->Server Runtime -》Tomcat Server
2、切換到Java Build Path界面中的Orader and Export,選擇Tomcat。

注意:
按以上方法操作時,若打開Server Runtime後一片空白,需要設置Apache服務器。設置方法爲:window->Preferences->Server->Runtime Environment -> add –> 選擇Apache的版本後點Next,再填入你apache服務器軟件的安裝(解壓後)地址。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章