导入项目时报错:The import javax.servlet.xxxx cannot be resolved

导入项目时报错:The import javax.servlet.xxxx cannot be resolved

如果eclipse已经把jar包都导入完了,那么出现这个错误的原因可能是这个项目没有绑定Tomcat。

  1. 右键项目 -> build path -> confugure build path
  2. 选择Libraries标签页,
  3. 如果有不需要的Tomcat,点击这个Tomcat,点击右边的remove按钮
    导入项目时报错:The import javax.servlet.xxxx cannot be resolved
  4. 点击右边的Add Librariy,选择Server Runtime -> next
    导入项目时报错:The import javax.servlet.xxxx cannot be resolved
  5. 选择自己需要的Tomcat服务器,点击finish。