Thymeleaf 3与Spring MVC 4 整合配置

Thymeleaf 3与Spring MVC 4 整合配置

Maven 依赖配置

Spring 相关依赖就不说了

<dependency>
      <groupId>org.thymeleaf</groupId>
      <artifactId>thymeleaf-spring4</artifactId>
      <version>3.0.2.RELEASE</version>
    </dependency>

通过三个bean整合,配置如下:

    <!-试图解析器->
  <bean id="viewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
    <property name="order" value="1" />
    <property name="characterEncoding" value="UTF-8" />
    <property name="templateEngine" ref="templateEngine" />
  </bean>
  <!-- 配置TemplateEngine -->
  <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
    <property name="templateResolver" ref="templateResolver" />
  </bean>
  <bean id="templateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
    <property name="prefix" value="/WEB-INF/thymeleaf/" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="HTML5" />
  </bean>
posted @ 2016-11-29 21:01  狐狸什妖  阅读(422)  评论(0编辑  收藏  举报