Skip to content

Commit

Permalink
thymeleaf 模版
Browse files Browse the repository at this point in the history
  • Loading branch information
yita committed May 17, 2015
1 parent ecbcc23 commit 241c368
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
11 changes: 11 additions & 0 deletions examples/quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,21 @@
<!-- WEB end -->

<!-- template engine begin-->
<!-- 如果要使用freemarker请去掉注释
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
-->

<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>

<!-- template engine end-->

Expand Down
48 changes: 38 additions & 10 deletions examples/quickstart/src/main/webapp/WEB-INF/spring-mvc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<property name="suffix" value=".jsp"/>
</bean>

<!-- 以下为freemarker的相关配置,如果使用freemarker请把注释去掉即可 -->
<!-- ***************************************************************************** -->
<!-- 以下为freemarker的相关配置,如果使用freemarker请把注释去掉即可 -->
<!-- -->
<!-- freemarker config 为了在freemarker中使用shiro tag用自定义的 -->
<!-- org.springside.modules.security.shiro.freemarker.ShiroTagFreeMarkerConfigurer -->
<!-- 代替 org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer -->
<!-- ***************************************************************************** -->
<!--
freemarker config 为了在freemarker中使用shiro tag
用自定义的
org.springside.modules.security.shiro.freemarker.ShiroTagFreeMarkerConfigurer
代替
org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer
-->
<bean id="freemarkerConfig" class="org.springside.modules.security.shiro.freemarker.ShiroTagFreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/views/"/>
<property name="freemarkerVariables">
Expand All @@ -63,18 +63,46 @@
</property>
</bean>
<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/>

-->
<!--
freemarker的order顺序一定早于jsp,否则不能正确查到
-->
<!--
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true"/>
<property name="order" value="0" />
<property name="prefix" value=""/>
<property name="suffix" value=".ftl"/>
</bean>


-->
<!-- **************************************************************** -->
<!-- THYMELEAF-SPECIFIC ARTIFACTS -->
<!-- TemplateResolver <- TemplateEngine <- ViewResolver -->
<!-- **************************************************************** -->

<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/templates/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
<!-- Template cache is true by default. Set to false if you want -->
<!-- templates to be automatically updated when modified. -->
<property name="cacheable" value="true" />
</bean>

<bean id="templateEngine"
class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<property name="order" value="0" />
<property name="viewNames" value="*.html,*.xhtml" />
</bean>



<!-- 容器默认的DefaultServletHandler处理 所有静态内容与无RequestMapping处理的URL-->
<mvc:default-servlet-handler/>

Expand Down
12 changes: 12 additions & 0 deletions modules/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<joda-time.version>2.7</joda-time.version>
<dozer.version>5.5.1</dozer.version>
<freemarker.version>2.3.22</freemarker.version>
<thymeleaf.version>2.1.3.RELEASE</thymeleaf.version>
<aspectj.version>1.8.5</aspectj.version>
<junit.version>4.12</junit.version>
<assertj.version>2.0.0</assertj.version>
Expand Down Expand Up @@ -658,6 +659,17 @@
<version>${freemarker.version}</version>
</dependency>

<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf.version}</version>
</dependency>

<!-- commons-pool -->
<!-- email -->
<dependency>
Expand Down

0 comments on commit 241c368

Please sign in to comment.