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

今天使用Eclipse+Maven創建了一個Javaweb工程,並在eclipse中配置了Web容器Jboss eap 6.2。新建jsp頁面,添加一個簡單java

的Java類。但是,JSP頁面頂端出現「紅色」的報錯信息:The superclass "javax.servlet.http.HttpServlet" was notweb

found on the Java Build Path。原來Javaweb工程類中沒有添加Web 容器Runtime相關類致使。api

錯誤提示:eclipse


 
解決方法很簡單,在pom.xml中添加以下配置便可:
jsp

1 <dependency>
2 <groupId>javax.servlet</groupId>
3 <artifactId>servlet-api</artifactId>
4 <version>2.5</version>
5 <scope>provided</scope>
6 </dependency>

 

補充:若是還提示錯誤,還能夠嘗試下面的方式:ide

一、右擊web工程-》屬性或Build Path-》Java Build Path->Libraries-> Add Libray...->Server Runtime -》JBoss 7.1 Runtimeui


 
二、切換到Java Build Path界面中的Orader and Export,選擇spa

相關文章
相關標籤/搜索