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. 设置自己的服务器