<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--这个配置文件与Spring的核心配置文件一样的 配置SpringMVC的内容 -->
<!-- 开启MVC注解驱动 -->
<mvc:annotation-driven/>
<!-- 配置注解扫描器 spingmvc的注解扫描器 扫描controller包
,springmvc.xml 扫描controller包的注解
context:include-filter:扫描controller-->
<context:component-scan base-package="com.hadwinling.controller">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--视图类型 默认jsp视图 (省略) -->
<!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>-->
<!-- 视图前缀 -->
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- 访问静态资源 404
http://localhost:8088/SpringMVC-01/js/jquery-3.4.1.js
前端控制器拦截所有请求,
配置静态资源不解析
location:路径
mapping:请求路径
-->
<mvc:resources location="/css/" mapping="/css/**"/> <!-- 样式 -->
<mvc:resources location="/images/" mapping="/images/**"/> <!-- 图片 -->
<mvc:resources location="/js/" mapping="/js/**"/> <!-- javascript -->
<!-- 配置文件解析器对象,要求id名称必须是multipartResolver -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 文件最大字节数 -->
<property name="maxUploadSize" value="10485760"/>
</bean>
<!-- 配置拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.hadwinling.interceptors.LoginInterceptor"></bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- 全局异常处理对象 -->
<bean class="com.hadwinling.execption.UserExecptionHandler"></bean>
</beans>