如在建立或匯入 Maven 項目到 Eclipse 開發環境中,看到出現 The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path in Eclipse 錯誤訊息,代表項目的 class path 找不到 http-servlet ,我們便需要把 http-servlet 加入至 class path。

解決方式:有兩種加入 class path 的方式。
1) 加入至 target runtime ,在項目列表右鍵單擊項目的選單,選擇 properties,選擇 Project Facets > Runtimes ,如 Runtimes 下已經有 servlet runtime 的依懶包,只需要直接勾選便可。如沒有,則需要點擊 New 按鈕新增後再勾選。
2) 直接在 Maven 的 pom.xml 下加入依懶配置。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
鏈結到這頁!