spring 3.0 spring - servlet. xml 설정

4417 단어 자바spring
이것 은 내 가 개발 하 는 데 자주 사용 하 는 spring 기본 설정 템 플 릿 입 니 다. 메모.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Bean   -->
<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:util="http://www.springframework.org/schema/util"
    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.0.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    <!--        -->
    <bean id="security" class="com.boaotech.util.Security"
        p:contextConfigLocation="WEB-INF/security.xml" />
    <!--       -->
    <bean id="menus" class="com.boaotech.util.Menus"
        p:contextConfigLocation="WEB-INF/menus.xml" p:security-ref="security" />

    <!-- Json        -->
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
    <!--                  -->
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
        <property name="webBindingInitializer"> 
            <bean class="com.boaotech.util.CommonBindingInitializer"/> 
        </property>
        <property name="messageConverters">
            <list>
                <ref bean="mappingJacksonHttpMessageConverter"/>
            </list>
        </property>
    </bean> 
    <!--   @Controller   -->
    <mvc:annotation-driven />
    <!--            ,   Bean                  -->
    <context:component-scan base-package="com.boaotech.zhaotaoerp" />
    <context:annotation-config/>
    <!--          -->
    <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
    <task:scheduler id="myScheduler" pool-size="1"/>
    <task:executor id="myExecutor" pool-size="1"/>
    <!--       -->
    <mvc:interceptors>
        <bean id="authorizeInterceptor" class="com.boaotech.util.AuthorizeInterceptor" />
    </mvc:interceptors>
    <!--             -->
    <!-- bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/ -->
    <!-- FreeMarker     -->
    <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
        <property name="freemarkerSettings">
            <props>
                <prop key="template_update_delay">5</prop>
                <prop key="default_encoding">UTF-8</prop>
                <prop key="locale">zh_CN</prop>
            </props>
        </property>
    </bean>
    <!--           ,              -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
        p:cache="true" p:prefix="" p:suffix=".ftl"
        p:contentType="text/html;charset=UTF-8"
        p:exposeRequestAttributes="true" p:exposeSessionAttributes="true"
        />
    <!-- bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/jsp/"
        p:suffix=".jsp" / -->
</beans>

좋은 웹페이지 즐겨찾기