問題描述:我在創建web jsp后,出現了java.servlet.http.httpservlet was not found on the Java Build Path錯誤異常……之前因為亂碼問題亂改一通,網上搜了好多教程也沒解決,還誤刪了tomatch導致出現這種報錯……
原因分析:在java web工程下沒有引入中間件(服務器tomcat)運行的library
解決辦法:
(1): 確認eclipse中server的運行環境是否有配置,設置方法為:Window → Preferences → Server → Runtime Environments →Add → 選擇Apache的版本后點Next,再填入你apache tomcat軟件的安裝(解壓后)目錄。
(2): 右擊web工程 → Build Path → Configure build path... → Java Build Path → Libraries → Add Libray... → Server Runtime →Next> → Apache Tomcat Server →Finish。
(3): 切換到Java Build Path界面中的Orader and Export,勾選Tomcat。
(4): 右擊web工程 → 屬性 → Project Facets → 點擊右側tab選擇Runtimes → 勾選tomcat → OK。
參考博客:
https://blog.csdn.net/dietime1943/article/details/75127417