一.项目出现 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解决方法:
1.在eclipse上选Window->Preferences->Server->Runtime Environment->点击Add(添加tomcat服务器)。
2.在工程上右击选择Build Path...->Library->Server Runtime->next->选择你的服务器。
3.点击Order and Export->在Apache Tomcat v7.0(你的服务器)前的方框上打钩
二.解决maven项目上有红叉,Cannot change version of project facet Dynamic web module to 3.1 。
原因是由于这个catalog比较老,用的servlet还是2.3的,而一般现在至少都是2.5,在Project Facets里面修改Dynamic web module为3.1的时候就会出现Cannot change version of project facet Dynamic web module to3.1。解决这个问题的步骤如下:
1.把Servlet改成3.1,打开项目的web.xml,改之前:
(不同版本(2.3-3.1)web.xml文件的schema头部声明链接:
http://blog.csdn.net/qq_16313365/article/details/53783288
转载自:http://blog.csdn.net/qq_16313365/article/details/53783288)
- <!DOCTYPE web-app PUBLIC
- "-//Sun Micro<a href="http://www.07net01.com/tags-system-0.html" class="infotextkey">system</a>s, Inc.//DTD Web Application 2.3//EN"
- "http://<a href="http://www.07net01.com/tags-Java-0.html" class="infotextkey">Java</a>.sun.com/dtd/web-app_2_3.dtd" >
- <web-app>
- <display-name>Archetype Created Web Application</display-name>
- </web-app>
改之后:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
</web-app>
2.修改项目的设置,在Navigator下打开项目.settings目录下的org.eclipse.jdt.core.prefs
改前:
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
把1.5改为1.8
3.打开org.eclipse.wst.common.component
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="test">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="http://my.oschina.net/u/2292000/blog/test"/>
<property name="java-output-path" value="http://my.oschina.net/test/target/classes"/>
</wb-module>
</project-modules>
将1.5.0改为1.6.0
4.打开org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.5"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
把<installed facet="java" version="1.5"/>改成<installed facet="java" version="1.8"/>,
把 <installed facet="jst.web" version="2.3"/>改成 <installed facet="jst.web" version="3.1"/>
5.返回eclipse界面,刷新工程。