<?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: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.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<!-- 扫描controller -->
	<context:component-scan base-package="**.*controller" />
	<context:annotation-config />

	<!-- 返回ResponseBody响应类型 -->
	<mvc:annotation-driven>
		<mvc:message-converters>
			<bean class="org.springframework.http.converter.StringHttpMessageConverter">
				<property name="supportedMediaTypes">
					<list>
						<value>text/html;charset=UTF-8</value>
					</list>
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>
	
	<!-- Jsp视图 -->
	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp" />
		<property name="suffix" value=".jsp" />
		<property name="contentType" value="text/html; charset=utf-8" />
		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
	</bean>

	<!-- i18n国际化 -->
	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
		<!-- 找不到key时用key作为返回值 -->
		<property name="useCodeAsDefaultMessage" value="false" />
		<!-- 资源刷新时间 -->
		<property name="cacheSeconds" value="60" />
		<!-- 资源文件列表 -->
		<property name="basenames">
			<list>
				<value>classpath:i18n/messages</value>
			</list>
		</property>
		<property name="defaultEncoding" value="UTF-8" />
	</bean>

	<!-- 配置静态资源，不被DispatcherServlet处理 -->
	<mvc:resources mapping="/resources/**" location="/resources/" />
	
	<!-- 上传文件配置 20*1024*1024即20M resolveLazily属性启用是为了推迟文件解析，以便捕获文件大小异常 -->
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<property name="maxUploadSize" value="20971520" />
		<property name="defaultEncoding" value="UTF-8" />
		<property name="resolveLazily" value="true" />
	</bean>

</beans>