spring 整合freemarker 实现模板继承

时间:2022-01-05 04:30:31
    <!--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">0</prop>
<prop key="default_encoding">UTF-8</prop>
<prop key="locale">zh_CN</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="block" value-ref="block" />
<entry key="override" value-ref="override" />
<entry key="extends" value-ref="extends" />
</map>
</property>
</bean>
<!--freemarker 模板继承配置-->
<bean id="block" class="cn.org.rapid_framework.freemarker.directive.BlockDirective" />
<bean id="override" class="cn.org.rapid_framework.freemarker.directive.OverrideDirective" />
<bean id="extends" class="cn.org.rapid_framework.freemarker.directive.ExtendsDirective" />