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

    <mvc:default-servlet-handler/>

    <aop:aspectj-autoproxy proxy-target-class="true"/>
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/html;charset=UTF-8</value>
                        <value>application/json;charset=UTF-8</value>
                    </list>
                </property>
                <property name="features">
                    <list>
                        <value>WriteMapNullValue</value>
                        <value>QuoteFieldNames</value>
                        <value>WriteDateUseDateFormat</value>
                        <!-- 禁用fastjson循环引用检测 -->
                        <value>DisableCircularReferenceDetect</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <!-- 为了加载拦截器 需要 日志拦截器 （登录拦截和权限拦截已在shiro实现，看实现 情况处理） -->
    <mvc:interceptors>
        <!-- 使用bean定义一个Interceptor，直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
        <!--<bean class="com.kmall.admin.interceptor.LogInterceptor"/>-->
        <mvc:interceptor>
            <mvc:mapping path="/**"/>
            <mvc:exclude-mapping path="/statics/**"/>
            <mvc:exclude-mapping path="/**/**.html"/>
            <mvc:exclude-mapping path="/**/**.js"/>
            <bean class="com.kmall.common.interceptor.LogInterceptor"/>
        </mvc:interceptor>
    </mvc:interceptors>

    <!-- Velocity视图解析器    默认视图  -->
    <bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="contentType" value="text/html;charset=UTF-8"/>
        <property name="viewNames" value="*.html"/>
        <property name="suffix" value=""/>
        <property name="dateToolAttribute" value="date"/>
        <property name="numberToolAttribute" value="number"/>
        <property name="toolboxConfigLocation" value="/WEB-INF/velocity-toolbox.xml"/>
        <!--是否使用spring对宏定义的支持-->
        <property name="exposeRequestAttributes" value="true"/>
        <property name="requestContextAttribute" value="rc"/>
        <property name="order" value="0"/>
    </bean>

    <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath" value="/WEB-INF/page/"/>
        <property name="velocityProperties">
            <props>
                <prop key="input.encoding">UTF-8</prop>
                <prop key="output.encoding">UTF-8</prop>
                <prop key="contentType">text/html;charset=UTF-8</prop>
            </props>
        </property>
    </bean>

    <!-- JSP视图解析器  -->
    <bean id="viewResolverJsp" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/page/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <!-- FreeMarker视图解析器 -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
        <property name="contentType" value="text/html; charset=utf-8"/>
        <property name="cache" value="false"/>
        <property name="viewNames" value="*.ftl"/>
        <property name="suffix" value=""/>
        <property name="order" value="2"/>
    </bean>

    <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/WEB-INF/page/"/>
    </bean>

    <bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="1000000000"/>
    </bean>

    <!-- Kaptcha验证码生成器 -->
    <bean name="producer" class="com.google.code.kaptcha.impl.DefaultKaptcha" scope="singleton">
        <property name="config">
            <bean class="com.google.code.kaptcha.util.Config">
                <constructor-arg>
                    <props>
                        <prop key="kaptcha.border">no</prop>
                        <prop key="kaptcha.textproducer.font.color">black</prop>
                        <prop key="kaptcha.textproducer.char.space">4</prop>
                        <prop key="kaptcha.textproducer.char.length">4</prop>
                        <prop key="kaptcha.textproducer.char.string">123456789</prop>
                    </props>
                </constructor-arg>
            </bean>
        </property>
    </bean>


</beans>