HttpServlet cannot be resolved to a type
異常現象:
錯誤提示:
- HttpServlet cannot be resolved to a type
問題:
發現HttpServlet這個類根本就找不到,於是乎問題找到了—-沒有這個庫;
解決思路:
引入相關庫.
本例中遇到是在tomcat使用嚮導創建Servlet後出現的現象.下面是解決方案:
1. 右鍵工程菜單—properties
2. 選擇Java Build Path → Libraries → AddLibrary
3. 選擇 Server Runtime
4. 設置自己的服務器