mvn archetype:generate -DgroupId=com.zhi-qingchun.testSpringMVC -DartifactId=testSpringMVC -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
这样maven就自动为咱们建立了一个web项目,在testSpringMVC文件夹下。 java
CounterWebApp |-src |---main |-----resources |-----webapp |-------index.jsp |-------WEB-INF |---------web.xml |-pom.xml
testSpringMVC\src\main\webapp\WEB-INF\web.xml中的doctype仍采用Servlet 2.3,明显太旧了(不知道maven为何一直保留这个版本),因此把 web
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
改成 shell
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>testSpringMVC</display-name> </web-app>
mvn eclipse:eclipse -Dwtpversion=2.0
此时已经能够把这个项目导入eclipse并在tomcat下运行了。 tomcat
单击选中刚导入的项目,再选择菜单File>New>Source Folder,输入src/main/java,点击Finish完成,以后项目以下图:
app