<?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-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.xsd">

    <!--配置自动扫描的包-->
    <context:component-scan base-package="xyz.nongfah" use-default-filters="false">
        <!--规定扫描的注解-->
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
    </context:component-scan>




    <!--静态页面，如html,css,js,images可以访问-->
    <mvc:default-servlet-handler />
    <!--注解驱动，以使得访问路径与方法的匹配可以通过注解配置-->
    <mvc:annotation-driven>
        <mvc:message-converters >
            <!-- 配置Fastjson支持 -->
            <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>


    <!--配置json返回处理-->
    <bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"></bean>
    <!--配置视图解析器：如何把contorller方法返回值解析为实际的物理视图-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!--自定义拦截器实现权限控制-->
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/home"/>
            <bean class="xyz.nongfah.admin.SecurityInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/home/**"/>
            <bean class="xyz.nongfah.admin.SecurityInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/rank"/>
            <bean class="xyz.nongfah.admin.SecurityInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/admin"/>
            <bean class="xyz.nongfah.admin.SecurityInterceptor"/>
        </mvc:interceptor>
        <mvc:interceptor>
            <mvc:mapping path="/index"/>
            <bean class="xyz.nongfah.admin.SecurityInterceptor"/>
        </mvc:interceptor>

    </mvc:interceptors>




</beans>
