网上搜到一些资料,按照其步骤操作,并不能成功。现将自己实际操作成功的步骤和问题记录下来。
1.打开navigator视图,编辑项目所在目录下的.project文件,添加
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
在 <buildSpec> </buildSpec>中加入
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
2.刷新项目,项目->右击->Properties->Project Facets->Modify Project,选择Java和DynamicWeb Module、javascript
Java版本选1.6 ,Dynamic Web Module选3.0,如果报错就选2.5。
3.如果有报错
1)import javax.servlet.http.HttpServletRequest等类似的错误
就用tomcat安装包下面lib里面的servlet-api.jar包,放到项目下的lib里面即可。
2)如果jsp页面不识别uri http://java.sun.com/jsp/jstl/core则是缺少jar包jstl.jar+standard.jar
3)如果jsp页面报错javax.servlet.jsp.jspexceptioncannot be resolve
导入tomcat里面lib下的jsp-api.jar
4.如果还有错误java compiler level does not match the version of the installed javaproject facet
在navigator视图下找到.settings文件,org.eclipse.wst.common.project.facet.core.xml配置文件
将版本改为1.6即可。
也可以在项目右键 properties选java compiler 将版本改为1.6. 出现不能识别@override时,也是修改此处java的版本。
Tomcat下的项目在此路径下
C:\Users\用户名\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps