<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	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/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
        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-3.0.xsd
        http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/task
		http://www.springframework.org/schema/task/spring-task-3.2.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.0.xsd">

	<context:component-scan base-package="com.qiankun.controller" />
	<mvc:annotation-driven />
    <mvc:default-servlet-handler/>
    <mvc:view-controller path="/" view-name="index"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>


    <!-- 配置多请求数据类型，如json xml-->
	<!-- 配置多请求数据类型，如json xml -->
	<bean id="annotationMethodHandlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<ref bean="jsonConverter" />
			</list>
		</property>
	</bean>

	<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
		<property name="supportedMediaTypes" value="application/json" />
	</bean>

	<mvc:interceptors>
		<bean class="com.qiankun.interceptor.LoginInterceptor" />
	</mvc:interceptors>
	
	<mvc:resources mapping="/resources/**" location="/resources/" />
	
	<!-- 支持上传文件 -->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="defaultEncoding" value="utf-8" />
        <property name="maxUploadSize" value="1024000000"/>
    </bean>
	
	<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <!-- 默认类型 -->
        <property name="defaultContentType" value="text/html" />
        <!-- 请求类型 -->
        <property name="mediaTypes">
            <map>
                <entry key="json" value="application/json" />
                <entry key="xml" value="application/xml" />
            </map>
        </property>
        <!-- 模板试图解析器 -->
        <property name="viewResolvers">
            <list>
                <!-- jsp模板解析器 -->
                <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
                    <property name="prefix" value="/WEB-INF/pages/" />
                    <property name="suffix" value=".jsp" />
                </bean>
                <!-- 可加入其他视图技术如 volacity jstl等 -->
            </list>
        </property>
        
        <!-- 数据试图解析器 -->
        <property name="defaultViews">
            <list>
                <!-- 输出为JSON数据 -->
                <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
                </bean>
                <!-- 输出为xml数据 -->
                <bean id="marshallingView" class="org.springframework.web.servlet.view.xml.MarshallingView">
                    <property name="marshaller">
                        <bean id="xStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
                            <property name="autodetectAnnotations" value="true" />
                        </bean>
                    </property>
                    <property name="contentType" value="application/xml" />
                </bean>
            </list>
        </property>

    </bean>
    
</beans>