applicationContext-mvc.xml 2.38 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
3 4 5
       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.xsd
eddie.woo's avatar
eddie.woo committed
6 7 8
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">


9 10 11 12
    <!-- **************************************************************** -->
    <!-- Spring-MVC配置 -->
    <!-- **************************************************************** -->
    <mvc:resources mapping="/**" location="/"/>
eddie.woo's avatar
eddie.woo committed
13

14 15 16 17 18 19
    <mvc:annotation-driven>
        <mvc:message-converters>
            <!-- <ref bean="fastJsonHttpMessageConverter" /> -->
            <ref bean="mappingJackson2HttpMessageConverter"/>
        </mvc:message-converters>
    </mvc:annotation-driven>
eddie.woo's avatar
eddie.woo committed
20

21 22 23 24 25 26 27 28 29 30 31 32
    <!-- **************************************************************** -->
    <!-- 整合Thymeleaf3 -->
    <!-- See: http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html -->
    <!-- **************************************************************** -->
    <bean id="templateResolver"
          class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
        <property name="prefix" value="/WEB-INF/templates/"/>
        <property name="suffix" value=".html"/>
        <property name="templateMode" value="HTML"/>
        <property name="cacheable" value="false"/>
        <property name="characterEncoding" value="UTF-8"/>
    </bean>
eddie.woo's avatar
eddie.woo committed
33

34 35 36 37 38 39 40
    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver"/>
        <property name="enableSpringELCompiler" value="true"/>
        <property name="additionalDialects">
            <set>
                <!-- Note the package would change to 'springsecurity3' if you are using
                    that version -->
41
                <bean class="org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect"/>
42 43 44
            </set>
        </property>
    </bean>
eddie.woo's avatar
eddie.woo committed
45

46 47 48 49 50
    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
        <property name="templateEngine" ref="templateEngine"/>
        <property name="characterEncoding" value="UTF-8"/>
        <property name="order" value="100"/>
    </bean>
eddie.woo's avatar
eddie.woo committed
51
</beans>