<?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:p="http://www.springframework.org/schema/p"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:task="http://www.springframework.org/schema/task"
	xsi:schemaLocation="  
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
        http://www.springframework.org/schema/context  
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
        http://www.springframework.org/schema/task  
		http://www.springframework.org/schema/task/spring-task-3.2.xsd">
        
	<import resource="applicationContext.xml"/>
	
	<!-- Handles HTTP GET requests for /static/** by efficiently serving 
		up static resources in the ${webappRoot}/static/ directory -->
	<mvc:resources mapping="/resources/**" location="/static/" order="0"/>
	<mvc:resources mapping="/static/**" location="file:${app.home}/static/" order="0"/>
	
	<!-- 自动扫描包下的所有类，使其认为spring mvc的控制器 -->
	<context:component-scan base-package="cn.com.qmth.stmms.common.controller,
					  cn.com.qmth.stmms.admin,
					  cn.com.qmth.stmms.api,
					  cn.com.qmth.stmms.file,
					  cn.com.qmth.stmms.mark,
					  cn.com.qmth.stmms.monitor">
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Component" />
	</context:component-scan>

	<task:annotation-driven /> 
	<mvc:annotation-driven />
 	
	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/resources/**"/>
			<mvc:exclude-mapping path="/static/**"/>
			<mvc:exclude-mapping path="/file/**"/>
			<mvc:exclude-mapping path="/api/**"/>
			<bean id="commonInterceptor" class="cn.com.qmth.stmms.common.interceptor.CommonInterceptor"></bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/admin/**" />
			<bean id="adminInterceptor" class="cn.com.qmth.stmms.admin.interceptor.AdminInterceptor"></bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/api/**" />
			<bean id="apiInterceptor" class="cn.com.qmth.stmms.api.interceptor.ApiInterceptor"></bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/mark/**" />
			<bean id="markInterceptor" class="cn.com.qmth.stmms.mark.interceptor.MarkInterceptor"></bean>
		</mvc:interceptor>
		<mvc:interceptor>
			<mvc:mapping path="/**" />
			<mvc:exclude-mapping path="/resources/**"/>
			<mvc:exclude-mapping path="/static/**"/>
			<mvc:exclude-mapping path="/file/**"/>
			<mvc:exclude-mapping path="/api/**"/>
			<bean id="methodInterceptor" class="cn.com.qmth.stmms.common.interceptor.MethodInterceptor"></bean>
		</mvc:interceptor>
	</mvc:interceptors>

	<!-- <bean
		class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
		<property name="mediaTypes">
			<map>
				<entry key="atom" value="application/atom+xml" />
				<entry key="html" value="text/html" />
				<entry key="json" value="application/json" />
			</map>
		</property>
		<property name="viewResolvers">
			<list>
				<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
				<bean
					class="org.springframework.web.servlet.view.InternalResourceViewResolver">
					<property name="prefix" value="/WEB-INF/jsp/" />
					<property name="suffix" value=".jsp" />
					<property name="exposedContextBeanNames">
						<list>
							<value>properties</value>
						</list>
					</property>
				</bean>
			</list>
		</property>
		<property name="defaultViews">
			<list>
				<bean
					class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
			</list>
		</property>
	</bean> -->
	
	<!-- 视图文件解析配置 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/views/"/>
		<property name="suffix" value=".jsp"/>
		<property name="exposedContextBeanNames">
			<list>
				<value>properties</value>
			</list>
		</property>
	</bean>
	<!-- Mapping exception to the handler view -->
	<!-- <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> 
		to /error.jsp -->
	<!-- <property name="defaultErrorView" value="error"/> <property name="exceptionMappings"> 
		<props> </props> </property> </bean> -->

	<!-- 配置SpringMVC @ResponseBody和@RequestBody注解 -->
	<bean
		class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
				<ref bean="jsonHttpMessageConverter" />
			</list>
		</property>
	</bean>

	<bean id="jsonHttpMessageConverter"
		class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
		<property name="supportedMediaTypes">
			<list>
				<value>application/json;charset=UTF-8</value>
			</list>
		</property>
	</bean>
	
	<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
	<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" >
		<property name="ignoreResourceNotFound" value="true" />
		<property name="locations">
			<list>
				<value>/WEB-INF/application.properties</value>
			</list>
		</property>
	</bean>
</beans> 