如何在spring的自定义导入ftl,如spring.ftl

时间:2014-09-15 03:21:52

标签: java spring spring-mvc

我的包com.caobug.client.support.view有分页宏pagination.ftlFreeMarkerConfigurer.java

FreeMarkerConfigurer.java:

public class FreeMarkerConfigurer extends org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer {
    @Override
    protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) {
        super.postProcessTemplateLoaders(templateLoaders);
        templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, ""));
    }
}

弹簧views.xml:

<bean id="freeMarkerConfigurer" class="com.caobug.client.support.view.FreeMarkerConfigurer">
    <property name="defaultEncoding" value="utf-8"/>
    <property name="templateLoaderPath" value="/WEB-INF/"/>
    <property name="freemarkerSettings">
        <props>
            <prop key="template_update_delay">10</prop>
            <prop key="locale">zh_CN</prop>
            <prop key="number_format">0.####</prop>
            <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
            <prop key="classic_compatible">true</prop>
            <prop key="template_exception_handler">ignore</prop>
        </props>
    </property>
    <property name="freemarkerVariables">
        <map>
            <entry key="shiro">
                <bean class="com.caobug.tags.account.ShiroTags"/>
            </entry>
            <entry key="messageTotal">
                <bean class="com.caobug.tags.account.MessageCountTag"/>
            </entry>
        </map>
    </property>
</bean>

demo.ftl:

<#import "/pagination.ftl" as pagination />

获取以下错误:

==> #import "/pagination.ftl" as pagination  [in template "demo.ftl" at line 1, column 1]
----------

我该怎么办?

0 个答案:

没有答案