构建Maven项目
修改web.xml配置文件
<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">
<display-name>Archetype Created Web Application</display-name>
</web-app>
添加Maven依赖
在web.xml中配置前端控制器DispatcherServlet
<!---------------------------------------------------------------------------------
SpringMvc 前端控制器
----------------------------------------------------------------------------------->
<servlet>
<servlet-name>SSM</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- contextConfigLocation 配置SpringMvc加载的配置文件(配置的处理器、映射器、适配器等)
如果没有配置contextConfigLocation,默认加载的是/WEB-INF/servlet名称-servlet.xml()
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SSM</servlet-name>
<!--
第一种: *.action 访问以.action结尾的请求地址,由DispatcherServlet进行解析
第二种: / 所有的访问地址都由DispatcherServlet进行解析,包括了静态资源文件,此种方式可以实现RESTful 风格的url
第三种: /* 这种配置是不对的
-->
<url-pattern>/</url-pattern>
</servlet-mapping>
<!------------------------------------------------------------------------------------
SpringMvc 前端控制器 END
-------------------------------------------------------------------------------------->