①springMVC必备jar包:
commons-logging-1.1.3.jar
spring-aop-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE.jar
spring-webmvc-4.0.0.RELEASE.jar
②web.xml的注解:可以按 alt+/ 提示出来
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>location</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map all requests to the DispatcherServlet for handling -->
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>url</url-pattern>
</servlet-mapping>
1.location:填写spring-mvc.xml文件的路径
2.url:填写指定过滤处理的请求地址,其中“/”为restFul风格请求方式
③spring-mvc.xml文件一些配置:
<!-- 使用注解的包,包括子集 --> 会自动扫描controller层
<context:component-scan base-package="controller" />
<!-- 视图解析器 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/" />
<property name="suffix" value=".jsp"></property>
</bean>
1.value="/":指定页面的地址
2.value=".jsp":指定页面的后缀名
⑤springMVC处理静态资源,在页面写/resources,会自动映射为/images
<mvc:resources mapping="/resources/**" location="/images/"/>