今天使用Eclipse+Maven建立了一個Javaweb工程,並在eclipse中配置了Web容器Jboss eap 6.2。新建jsp頁面,添加一個簡單
的Java類。可是,JSP頁面頂端出現“紅色”的報錯信息:The superclass "javax.servlet.http.HttpServlet" was not
found on the Java Build Path。原來Javaweb工程類中沒有添加Web 容器Runtime相關類導致。
錯誤提示:
解決方法很簡單,在pom.xml中添加如下配置即可:
1 <dependency> 2 <groupId>javax.servlet</groupId> 3 <artifactId>servlet-api</artifactId> 4 <version>2.5</version> 5 <scope>provided</scope> 6 </dependency>
補充:如果還提示錯誤,還可以嘗試下面的方式:
1、右擊web工程-》屬性或Build Path-》Java Build Path->Libraries-> Add Libray...->Server Runtime -》JBoss 7.1 Runtime
2、切換到Java Build Path界面中的Orader and Export,選擇
