一、在eclipse中创建maven-archetype-webapp项目:
1.新建项目选择maven项目
2.默认,下一步
3.选择maven-archetype-webapp,其他保持默认即可
4.如下填写完成后,点击完成即可
5.创建完成后的maven项目结构如下
其中index.jsp报错,错误信息:Multiple annotations found at this line: - The superclass “javax.servlet.http.HttpServlet” was not found on the Java
* 意思是缺少servlet包,我们可以导入javax.servlet-api-3.1.0.jar包,我们可以用两种方式来处理:*
* 1> 在pom.xml中的dependencies中加入依赖包*
1 <dependency>
2 <groupId>javax.servlet</groupId>
3 <artifactId>javax.servlet-api</artifactId>
4 <version>3.1.0</version>
5 </dependency>
2> 可以在build path中添加tomcat 库,如下
点击next出现下面界面,如下操作
至此,一个正常的maven web项目已经建好,如下:
二、配置springMVC
1.在pom.xml中添加对spring的依赖
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>HelloSpringMVC</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version&g