日期:2014-05-17  浏览次数:20640 次

eclipse中的web工程导入myeclipse中,出现servlet错误,怎么解决?
一个eclipse中开发的web工程,导入进myeclipse中,在启动tomcat时,提示

The import javax.servlet.http.HttpSession cannot be resolved
The import javax.servlet.http.HttpSessionEvent cannot be resolved
The import javax.servlet.http.HttpSessionListener cannot be resolved
HttpSessionListener cannot be resolved to a type
HttpSessionEvent cannot be resolved to a type
HttpSessionEvent cannot be resolved to a type

错误,从网上查找来看,是缺少了servlet-api.jar文件,把tomcat/lib下的servlet-api.jar文件拷入到工程的lib目录下,重新启动tomcat,又报告如下错误:
validateJarFile(C:\Tomcat7\webapps\PDEInterface\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

通过在eclipse中,两个工程比较来看,eclipse中在build path中通过add library中选择了Server runtime,使用了tomcat/lib目录下的包,而myeclipse中却没有这个选项。在myeclipse中把tomcat/lib目录下的包通过Add external folder加入到工程中,还是无法启动tomcat。
请问,如何设置,才能让工程在myeclipse中正常使用?
------解决方案--------------------
检查一下myeclipse中配置的JDK是不是JDK版本冲突了。。
------解决方案--------------------
JDK版本的问题检查过了,都是用的1.6
------解决方案--------------------
检查jdk的版本
------解决方案--------------------
servet api没有导入么?
------解决方案--------------------
我感觉是服务器的问题,用的是应用程序,而不是web的tomcat服务器。

------解决方案--------------------
问题解决了。
出现这个问题,是eclipse和myeclipse建立工程不一样。