将web项目导入到eclipseMyEclipse中常见错误

xiaoxiao2021-02-28  97

错误1:string cannot be resolved to a type  原因:这种情况一般是因为你的JDK版本没有设置好,或者设置的有不一致的地方。  解决方案:    1.首先检查window->preferences->Java->compiler 和Installed JRE的版本是否一致,不一致请设置一致它。这时候如果还报错请看第二步。    2.在项目上右键->properties->Java Build Path->Libraries中检查其中的JRE跟你在第一步设置的JRE版本是否一致,应该是不一致的,那么删掉原来这个JRE然后Add Library添加上第一步中设置的Library,点击确定就可以不报错啦~ 错误2: The import javax.servlet cannot be resolved 原因: 开发servlet需要servlet-api.jar包没有添加到相应目录(如应用服务器的目录、WEB应用中的WEB-INF/lib)中; 这个包是tomcat里面的,并不在JDK当中 解决方案:

tomcat下的common目录下的lib目录有对servlet支持的jarservlet-api.jar ,需要把它加进来

错误3The import org.apache.catalina cannot be resolved

解决方案:

先确认项目添加到了tomcat

项目-右键点击properties,选择Targeted runtimes 勾选apache tomcat 然后应用

错误4: javax.servlet.jsp.PageContext cannot be resolved to a type javax.servlet.jsp.JspException cannot be resolved to a type

解决方案:

这个异常需要加入:jsp-api.jar和servlet-api.jar

tomcat下的common目录下的lib目录中。

原文地址:http://blog.csdn.net/greenhandcgl/article/details/51536414

转载请注明原文地址: https://www.6miu.com/read-77733.html

最新回复(0)