eclipse 导入web项目时常见错误

1. JavaWeb:报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

解决方法:右击web工程-》属性或Build Path-》Java Build Path->Libraries-> Add Libray...->Server Runtime -》Tomcat Server

切换到Java Build Path界面中的Orader and Export,选择Tomcat。

按以上方法操作时,若打开Server Runtime后一片空白,需要设置Apache服务器。设置方法为:window->Preferences->Server->Runtime Environment -> add --> 选择Apache的版本后点Next,再填入你apache服务器软件的安装(解压后)地址。

2.导入后中文显示乱码

导入项目之前,请确认工作空间编码已设置为utf-8:window->Preferences->General->Wrokspace->Text file encoding->Other 选择UTF-8

3.导入后,由于你的开发环境中JRE以及Tomcat Library名称可能和源代码中的不一致,可能会出现Build Path的错误

解决方法如下:右键project->Build Path->Configure Build Path->选择Libraries tab页->删除带小红叉的Library->点击Add Library->选择JRE System Library(删了Tomcat Library的话就选择Server Runtime)->选择一个JRE后->Finish。

4.Tomcat版本不一样

进入项目包下的.settings目录,找到org.eclipse.wst.common.project.facet.core.xml文件,用记事本打开后才发现这句话有问题:《runtime name="Apache Tomcat v6.0"/》。我eclipse中设置的tomcat是7.0版本的,而它的运行环境是6.0版本的tomcat,肯定会出现问题。于是把这句话删掉,正常

建议做完以上操作后,重新启动eclipse,有时做完更改后需要重新启动才能生效

4.the import com.csii cannot be resolved 

问题:eclipse 导入类 提示The import XXX cannot be resolved

原因:原来使用JDK和现在使用的JDK不同造成的buildpath不对

解决方法:

1、右键项目-------buildpath--------最下面那个configura;

2、选择libraries找到JRE;

3、选中remove掉,重新为该项目选择一个JRE;

4、project----clean,全部的包都找到了。

原文地址:https://www.cnblogs.com/gaoguofeng/p/5362708.html