<?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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- 因为采用了注解配置,要启用注解配置 -->
<mvc:annotation-driven />
<!-- 把程序中的所有控制器类扫描SpringMVC的框架中,也就是实体控制器对象-->
<context:component-scan base-package="com.etc.controller"/>
<!-- 继承类的方式实现控制器类,1.添加参数分解器类 2.实例化控制器,并关联参数分解器
<bean id="parameterMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="action"/>
</bean>
<bean name="/grade" class="com.etc.controller.GradeController">
<property name="methodNameResolver">
<ref bean="parameterMethodNameResolver"/>
</property>
</bean>
-->
<!-- 这个配置是配实现接口的方式实现的控制器 class表示类,name:表示访问这个类的URL
<bean name="/teacher/list" class="com.etc.controller.TeacherController"></bean>-->
<!-- 配置校验器 -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
<property name="validationMessageSource" ref="hierarchicalMessageSource"></property>
</bean>
<!-- 配置验证消息 -->
<bean id="hierarchicalMessageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"></bean>
<!-- 配置静态资源不拦截过滤 -->
<!--<mvc:default-servlet-handler/> -->
<mvc:resources location="/images/" mapping="/images/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/css/" mapping="/css/**"/>
<!-- 文件上传的配置 -->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 上传的文件的大小单位是字节数 1024byte->1KB 1024KB->1MB 1024MB->1GB
4194304=4MB 如果同时传多个文件,要求多个文件和的大小不能超过这个这个值
-->
<property name="maxUploadSize" value="4194304"/>
<!-- 缓冲区大小 -->
<property name="maxInMemorySize" value="4096"/>
<!-- 设置编码格式 -->
<property name="defaultEncoding" value="utf-8"/>
</bean>
<!-- 视图分解器的配置,前缀与后缀用于拼接控制器类中的方法返回的视图名称。最终得到视图的具体路径.. -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀:/表示项目的根据目录 -->
<property name="prefix" value="/"/>
<!-- 后缀,控制器中只需要返回视图的名称,则框架会根据视图名称加上前缀与后缀,得到最终视图路径 -->
<property name="suffix" value=".jsp"/>
</bean>
</beans>