首先,eclipse中创建一个Dynamic Web Project
Target runtime选择 Tomcat6
一直next,最后勾选“generate web.xml deployment descriptor”
导入相关的jar包(可以在我的百度网盘下载,链接:http://pan.baidu.com/s/1boT9vLP 密码:h439)
规划包的目录结构
修改web.xml文件:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring-context.xml</param-value>
</context-param>
<!--负责启动Spring容器的监听器,引用上下文参数获得Spring配置文件的地址-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--spring MVC的主控Servlet-->
<servlet>
<servlet-name>spring</