Java 类org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer 实例源码

项目:uaa-service    文件:TemplateConfig.java   
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
    final FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();

    // If overwritten use path of user
    if (isNotBlank(uaaProperties.getTemplatePath())) {
        final TemplateLoader templateLoader = getTemplateLoader(uaaProperties.getTemplatePath());
        factory.setPreTemplateLoaders(templateLoader);
    }

    // Default configurations
    factory.setPostTemplateLoaders(getTemplateLoader("classpath:/templates/"));
    factory.setDefaultEncoding("UTF-8");

    final FreeMarkerConfigurer result = new FreeMarkerConfigurer();
    result.setConfiguration(factory.createConfiguration());
    return result;
}
项目:onetwo    文件:WebFtlsContextConfig.java   
@Bean
    @ConditionalOnMissingBean({FreeMarkerConfig.class, FreeMarkerViewResolver.class})
    public FreeMarkerConfigurer freeMarkerConfigurer() {
        PluginFreeMarkerConfigurer configurer = new PluginFreeMarkerConfigurer();
        applyProperties(configurer);
        String[] paths = this.properties.getTemplateLoaderPath();
//      paths = ArrayUtils.add(paths, WEBFTLS_PATH);
        configurer.setTemplateLoaderPaths(paths);

        List<WithAnnotationBeanData<FreeMarkerViewTools>> tools = SpringUtils.getBeansWithAnnotation(applicationContext, FreeMarkerViewTools.class);
        tools.forEach(t->{
            String name = t.getAnnotation().value();
            if(StringUtils.isBlank(name)){
                name = t.getBean().getClass().getSimpleName();
            }
            configurer.setFreemarkerVariable(name, t.getBean());
            logger.info("registered FreeMarkerViewTools : {}", name);
        });
        return configurer;
    }
项目:kansalaisaloite    文件:EmailServiceImpl.java   
public EmailServiceImpl(FreeMarkerConfigurer freemarkerConfig, MessageSource messageSource, JavaMailSender javaMailSender, 
                    String baseURL, String defaultReplyTo, String sendToOM, String sendToVRK, 
                    int invitationExpirationDays, String testSendTo, boolean testConsoleOutput) {
    this.freemarkerConfig = freemarkerConfig;
    this.messageSource = messageSource;
    this.javaMailSender = javaMailSender;
    this.baseURL = baseURL;
    this.defaultReplyTo = defaultReplyTo;
    this.invitationExpirationDays = invitationExpirationDays;
    this.sendToOM = sendToOM;
    this.sendToVRK = sendToVRK;

    if (Strings.isNullOrEmpty(testSendTo)) {
        this.testSendTo = null;
    } else {
        this.testSendTo = testSendTo;
    }
    this.testConsoleOutput = testConsoleOutput;
}
项目:TeeFun    文件:MvcConfig.java   
@Bean
public FreeMarkerConfigurer getFreemarkerConfig() throws IOException, TemplateException {
    final FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/WEB-INF/views/");
    factory.setDefaultEncoding("UTF-8");
    final Properties properties = new Properties();
    properties.put("auto_import", "spring.ftl as spring");
    properties.put("template_exception_handler", "rethrow");
    factory.setFreemarkerSettings(properties);
    final Map<String, Object> sharedVariables = new HashMap<String, Object>();
    sharedVariables.put("include", this.freemarkerIncludeDirective);
    factory.setFreemarkerVariables(sharedVariables);
    factory.setPreferFileSystemAccess(false);

    final FreeMarkerConfigurer result = new FreeMarkerConfigurer();
    // FIXME factory not working
    // result.setConfiguration(factory.createConfiguration());
    result.setTemplateLoaderPath("/WEB-INF/views/");
    result.setFreemarkerVariables(sharedVariables);
    result.setFreemarkerSettings(properties);

    return result;
}
项目:GMM    文件:ApplicationConfiguration.java   
/**
 * FreeMarker (ftl) configuration
 */
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
    final FreeMarkerConfigurer result = new FreeMarkerConfigurer();

    // template path
    result.setTemplateLoaderPath("/WEB-INF/ftl/");
    result.setDefaultEncoding("UTF-8");

    // static access
    final Version version = freemarker.template.Configuration.getVersion();
    final BeansWrapper wrapper = new BeansWrapper(version);
    final TemplateHashModel statics = wrapper.getStaticModels();
    final Map<String, Object> shared = new HashMap<>();
    for (final Class<?> clazz : ElFunctions.staticClasses) {
        shared.put(clazz.getSimpleName(), statics.get(clazz.getName()));
    }
    result.setFreemarkerVariables(shared);

    return result;
}
项目:emergentmud    文件:HttpConfiguration.java   
@Bean
public FreeMarkerConfigurer configureFreemarker() {
    FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
    Properties settings = new Properties();

    settings.setProperty(freemarker.template.Configuration.TEMPLATE_EXCEPTION_HANDLER_KEY, "rethrow");
    freeMarkerConfigurer.setFreemarkerSettings(settings);
    freeMarkerConfigurer.setTemplateLoaderPath(FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH);

    return freeMarkerConfigurer;
}
项目:nixmash-blog    文件:MailConfig.java   
@Bean
public FreeMarkerConfigurer freemarkerConfigurer() throws IOException {
    FreeMarkerConfigurer result = new FreeMarkerConfigurer();
    if (nixmashModeEnabled)
        result.setTemplateLoaderPath("classpath:/nixmarker/");
    else
        result.setTemplateLoaderPath("classpath:/freemarker/");
    return result;
}
项目:spring4-understanding    文件:ViewResolverRegistry.java   
/**
 * Register a FreeMarker view resolver with an empty default view name
 * prefix and a default suffix of ".ftl".
 *
 * <p><strong>Note</strong> that you must also configure FreeMarker by adding a
 * {@link org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer} bean.
 */
public UrlBasedViewResolverRegistration freeMarker() {
    if (this.applicationContext != null && !hasBeanOfType(FreeMarkerConfigurer.class)) {
        throw new BeanInitializationException("In addition to a FreeMarker view resolver " +
                "there must also be a single FreeMarkerConfig bean in this web application context " +
                "(or its parent): FreeMarkerConfigurer is the usual implementation. " +
                "This bean may be given any name.");
    }
    FreeMarkerRegistration registration = new FreeMarkerRegistration();
    this.viewResolvers.add(registration.getViewResolver());
    return registration;
}
项目:spring4-understanding    文件:ViewResolverRegistryTests.java   
@Before
public void setUp() {
    StaticWebApplicationContext context = new StaticWebApplicationContext();
    context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class);
    context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
    context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
    context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
    context.registerSingleton("scriptTemplateConfigurer", ScriptTemplateConfigurer.class);
    this.registry = new ViewResolverRegistry();
    this.registry.setApplicationContext(context);
    this.registry.setContentNegotiationManager(new ContentNegotiationManager());
}
项目:my-paper    文件:FreemarkerUtils.java   
/**
 * 解析字符串模板
 * 
 * @param template
 *            字符串模板
 * @param model
 *            数据
 * @return 解析后内容
 */
public static String process(String template, Map<String, ?> model) throws IOException, TemplateException {
    Configuration configuration = null;
    ApplicationContext applicationContext = SpringUtils.getApplicationContext();
    if (applicationContext != null) {
        FreeMarkerConfigurer freeMarkerConfigurer = SpringUtils.getBean("freeMarkerConfigurer", FreeMarkerConfigurer.class);
        if (freeMarkerConfigurer != null) {
            configuration = freeMarkerConfigurer.getConfiguration();
        }
    }
    return process(template, model, configuration);
}
项目:xxl-incubator    文件:HtmlGenerateServiceImpl.java   
/**
 * html分页工具
 * @param allList           :   html分页列表
 * @param pagesize          :   每页显示记录数量
 * @param templatePathName  :   模板页面,完整地址 (相相对于freeamrker配置根目录)
 * @param filePath          :   html文件,路径目录 --/-/
 * @param index             :   html文件,默认前缀 index
 */
private static void generateHtmlPagination(FreeMarkerConfigurer freemarkerConfig, List<?> allList, Map<String, Object> paramMap,int pagesize, String templatePathName , String filePath , String index){
    int allCount = allList!=null?allList.size():0;

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("pageNumAll", 1);
    params.put("pageNum", 1);
    params.put("filePath", filePath);
    params.put("index", index);

    if (MapUtils.isNotEmpty(paramMap)) {
        params.putAll(paramMap);
    }

    if (allCount > 0) {
        int pageNumAll = allCount%pagesize==0 ? allCount/pagesize : allCount/pagesize + 1;
        for (int pageNum = 1; pageNum <= pageNumAll; pageNum++) {
            params.put("pageNumAll", pageNumAll);
            params.put("pageNum", pageNum);

            int from = (pageNum-1)*pagesize;
            int to = (from + pagesize) <= allCount ? (from + pagesize) : allCount;
            params.put("pageList", allList.subList(from, to));

            String fileName = (pageNum==1) ? index : (index + "_" + pageNum);
            HtmlTemplateUtil.generate(freemarkerConfig, params, templatePathName, filePath + fileName + ".html");
        }
    } else {
        params.put("pageNumAll", 0);
        HtmlTemplateUtil.generate(freemarkerConfig, params, templatePathName, filePath + index + ".html");
    }
}
项目:xxl-incubator    文件:HtmlTemplateUtil.java   
/**
 * 生成HTML字符串
 * 
 * @param content           : 页面传参
 */
public static String generateString(FreeMarkerConfigurer freemarkerConfig, Map<?, ?> content, String templateName) {
    String htmlText = "";
    try {
        // 通过指定模板名获取FreeMarker模板实例
        Template tpl = freemarkerConfig.getConfiguration().getTemplate(templateName);
        htmlText = FreeMarkerTemplateUtils.processTemplateIntoString(tpl, content);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return htmlText;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FreeMarkerAutoConfigurationTests.java   
@SuppressWarnings("deprecation")
@Test
public void customFreeMarkerSettings() {
    registerAndRefreshContext("spring.freemarker.settings.boolean_format:yup,nope");
    assertThat(this.context.getBean(FreeMarkerConfigurer.class).getConfiguration()
            .getSetting("boolean_format")).isEqualTo("yup,nope");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FreeMarkerAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    FreeMarkerConfigurer freemarker = this.context
            .getBean(FreeMarkerConfigurer.class);
    StringWriter writer = new StringWriter();
    freemarker.getConfiguration().getTemplate("message.ftl").process(this, writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:singular-server    文件:ServerStudioWebMVCConfig.java   
@Bean
public FreeMarkerConfigurer freemarkerConfig() {
    FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
    freeMarkerConfigurer.setTemplateLoaderPath("/freemarker/view");
    freeMarkerConfigurer.setDefaultEncoding("UTF-8");
    freeMarkerConfigurer.setPreferFileSystemAccess(false);
    return freeMarkerConfigurer;
}
项目:spring-boot-concourse    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:spring-boot-concourse    文件:FreeMarkerAutoConfigurationTests.java   
@SuppressWarnings("deprecation")
@Test
public void customFreeMarkerSettings() {
    registerAndRefreshContext("spring.freemarker.settings.boolean_format:yup,nope");
    assertThat(this.context.getBean(FreeMarkerConfigurer.class).getConfiguration()
            .getSetting("boolean_format")).isEqualTo("yup,nope");
}
项目:spring-boot-concourse    文件:FreeMarkerAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    FreeMarkerConfigurer freemarker = this.context
            .getBean(FreeMarkerConfigurer.class);
    StringWriter writer = new StringWriter();
    freemarker.getConfiguration().getTemplate("message.ftl").process(this, writer);
    assertThat(writer.toString()).contains("Hello World");
}
项目:music-for-all-application    文件:WebAppConfig.java   
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
    final FreeMarkerConfigurer conf = new FreeMarkerConfigurer();
    conf.setTemplateLoaderPath("/WEB-INF/views/");
    conf.setDefaultEncoding("UTF-8");
    return conf;
}
项目:music-for-all-application    文件:MailConfig.java   
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
    final FreeMarkerConfigurer conf = new FreeMarkerConfigurer();
    conf.setTemplateLoaderPath("/WEB-INF/views/mails/");
    conf.setDefaultEncoding("UTF-8");
    return conf;
}
项目:kc-rice    文件:UifUnitTestUtils.java   
/**
 * Create a web application context suitable for FreeMarker unit testing.
 */
private static void configureKradWebApplicationContext() {
    MockServletContext sctx = new MockServletContext();
    StaticWebApplicationContext ctx = new StaticWebApplicationContext();
    ctx.setServletContext(sctx);

    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.add("preferFileSystemAccess", false);
    mpv.add("templateLoaderPath", "/krad-web");
    Properties props = new Properties();
    props.put("number_format", "computer");
    props.put("template_update_delay", "2147483647");
    mpv.add("freemarkerSettings", props);
    ctx.registerSingleton("freemarkerConfig", FreeMarkerConfigurer.class, mpv);

    mpv = new MutablePropertyValues();
    mpv.add("cache", true);
    mpv.add("prefix", "");
    mpv.add("suffix", ".ftl");
    ctx.registerSingleton("viewResolver", FreeMarkerViewResolver.class, mpv);

    ctx.registerSingleton("freeMarkerInputBootstrap", FreeMarkerInlineRenderBootstrap.class);

    ctx.refresh();
    ctx.start();
    sctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    webApplicationContext = ctx;
}
项目:contestparser    文件:FreeMarkerAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(FreeMarkerConfig.class)
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    applyProperties(configurer);
    return configurer;
}
项目:contestparser    文件:FreeMarkerAutoConfigurationTests.java   
@SuppressWarnings("deprecation")
@Test
public void customFreeMarkerSettings() {
    registerAndRefreshContext("spring.freemarker.settings.boolean_format:yup,nope");
    assertThat(this.context.getBean(FreeMarkerConfigurer.class).getConfiguration()
            .getSetting("boolean_format"), equalTo("yup,nope"));
}
项目:contestparser    文件:FreeMarkerAutoConfigurationTests.java   
@Test
public void renderTemplate() throws Exception {
    registerAndRefreshContext();
    FreeMarkerConfigurer freemarker = this.context
            .getBean(FreeMarkerConfigurer.class);
    StringWriter writer = new StringWriter();
    freemarker.getConfiguration().getTemplate("message.ftl").process(this, writer);
    assertThat(writer.toString(), containsString("Hello World"));
}
项目:molgenis-bbmri-eric    文件:WebAppConfig.java   
/**
 * Configures Freemarker
 */
@Override
public FreeMarkerConfigurer freeMarkerConfigurer()
{
    FreeMarkerConfigurer result = super.freeMarkerConfigurer();
    // Look up unknown templates in the FreemarkerTemplate repository
    result.setPostTemplateLoaders(new RepositoryTemplateLoader(dataService));
    return result;
}
项目:openyu-commons    文件:SpringFreeMarkerManager.java   
protected Configuration createConfiguration(ServletContext servletContext)
    throws TemplateException
{
    Configuration configuration = null;
    //Configuration configuration = super.createConfiguration(servletContext);

    ApplicationContext applicationContext = SpringHelper.getApplicationContext(servletContext);

    //configuration
    FreeMarkerConfigurer freeMarkerConfigurer = (FreeMarkerConfigurer) applicationContext
            .getBean(FREE_MARKER_CONFIGURER);
    configuration = freeMarkerConfigurer.getConfiguration();

    //directive
    Map<String, TemplateDirectiveModel> beans = applicationContext
            .getBeansOfType(TemplateDirectiveModel.class);
    for (Map.Entry<String, TemplateDirectiveModel> entry : beans.entrySet())
    {
        String key = entry.getKey();
        TemplateDirectiveModel value = entry.getValue();
        if (value instanceof TemplateDirectiveModel)
        {
            configuration.setSharedVariable(key, value);
        }
    }
    //
    return configuration;

}
项目:kansalaisaloite    文件:AppConfiguration.java   
@Bean 
public FreeMarkerConfigurer freemarkerConfig() {
    FreeMarkerConfigurer config = new FreeMarkerConfigurer();
    config.setDefaultEncoding("UTF-8");
    String[] paths = {"/WEB-INF/freemarker/", "classpath:/freemarker/"}; 
    config.setTemplateLoaderPaths(paths);

    Map<String, Object> variables = Maps.newHashMap();
    variables.put("xml_escape", fmXmlEscape());

    config.setFreemarkerVariables(variables);
    return config;
}
项目:kansalaisaloite    文件:AppConfiguration.java   
@Bean
public BeansWrapper freemarkerObjectWrapper(FreeMarkerConfigurer freeMarkerConfigurer) {
    boolean testFreemarkerShowErrorsOnPage = env.getProperty(PropertyNames.testFreemarkerShowErrorsOnPage, Boolean.class, TEST_FREEMARKER_SHOW_ERRORS_ON_PAGE_DEFAULT);
    if (!testFreemarkerShowErrorsOnPage) {
        freeMarkerConfigurer.getConfiguration().setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    } 
    return (BeansWrapper) freeMarkerConfigurer.getConfiguration().getObjectWrapper();
}
项目:kansalaisaloite    文件:AppConfiguration.java   
@Bean
public EmailService emailService(FreeMarkerConfigurer freeMarkerConfigurer) {

    String baseURL = env.getRequiredProperty(PropertyNames.baseURL);
    String defaultReplyTo = env.getRequiredProperty(PropertyNames.emailDefaultReplyTo);
    String sendToOM = env.getRequiredProperty(PropertyNames.emailSendToOM);
    String sendToVRK = env.getRequiredProperty(PropertyNames.emailSendToVRK);
    int invitationExpirationDays = env.getRequiredProperty(PropertyNames.invitationExpirationDays, Integer.class);

    String testSendTo = env.getProperty(PropertyNames.testEmailSendTo);
    boolean testConsoleOutput = env.getProperty(PropertyNames.testEmailConsoleOutput, Boolean.class, TEST_EMAIL_CONSOLE_OUTPUT_DEFAULT);
    return new EmailServiceImpl(freeMarkerConfigurer, messageSource(), javaMailSender(), baseURL, defaultReplyTo, sendToOM, sendToVRK, invitationExpirationDays, testSendTo, testConsoleOutput);
}
项目:spring-cloud-netflix    文件:HystrixDashboardConfiguration.java   
/**
 * Overrides Spring Boot's {@link FreeMarkerAutoConfiguration} to prefer using a
 * {@link SpringTemplateLoader} instead of the file system. This corrects an issue
 * where Spring Boot may use an empty 'templates' file resource to resolve templates
 * instead of the packaged Hystrix classpath templates.
 * @return FreeMarker configuration
 */
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setTemplateLoaderPaths(DEFAULT_TEMPLATE_LOADER_PATH);
    configurer.setDefaultEncoding(DEFAULT_CHARSET);
    configurer.setPreferFileSystemAccess(false);
    return configurer;
}
项目:mtools    文件:FreemarkerUtils.java   
public static String process(String template, Map model)
{
    Configuration configuration = null;
    FreeMarkerConfigurer freemarkerconfigurer = (FreeMarkerConfigurer)SpringUtil.getBean("freeMarkerConfigurer", FreeMarkerConfigurer.class);
    if(freemarkerconfigurer != null)
        configuration = freemarkerconfigurer.getConfiguration();
    return process(template, model, configuration);
}
项目:rice    文件:UifUnitTestUtils.java   
/**
 * Create a web application context suitable for FreeMarker unit testing.
 */
private static void configureKradWebApplicationContext() {
    MockServletContext sctx = new MockServletContext();
    StaticWebApplicationContext ctx = new StaticWebApplicationContext();
    ctx.setServletContext(sctx);

    MutablePropertyValues mpv = new MutablePropertyValues();
    mpv.add("preferFileSystemAccess", false);
    mpv.add("templateLoaderPath", "/krad-web");
    Properties props = new Properties();
    props.put("number_format", "computer");
    props.put("template_update_delay", "2147483647");
    mpv.add("freemarkerSettings", props);
    ctx.registerSingleton("freemarkerConfig", FreeMarkerConfigurer.class, mpv);

    mpv = new MutablePropertyValues();
    mpv.add("cache", true);
    mpv.add("prefix", "");
    mpv.add("suffix", ".ftl");
    ctx.registerSingleton("viewResolver", FreeMarkerViewResolver.class, mpv);

    ctx.registerSingleton("freeMarkerInputBootstrap", FreeMarkerInlineRenderBootstrap.class);

    ctx.refresh();
    ctx.start();
    sctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    webApplicationContext = ctx;
}
项目:frame_smh    文件:TemplateFreemarkerManager.java   
public void setFreeMarkerConfigurer(FreeMarkerConfigurer freeMarkerConfigurer) {
    this.freeMarkerConfigurer = freeMarkerConfigurer;
    Configuration configuration = freeMarkerConfigurer.getConfiguration();
       configuration.setSharedVariable("millisToDateTime", new MillisToDateTimeFreemarkerModel());
       configuration.setSharedVariable("empty", new EmptyFreemarkerModel());
       configuration.setSharedVariable("escapeHtml", new EscapeHtmlFreemarkerModel());
       configuration.setSharedVariable("unescapeHtml", new UnescapeHtmlFreemarkerModel());
}
项目:mev    文件:ViewResolverConfiguration.java   
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer () {
  FreeMarkerConfigurer configurer = new FreeMarkerConfigurer ();
  configurer.setTemplateLoaderPath ("classpath:");
  configurer.setPreferFileSystemAccess (false);
  return configurer;
}
项目:molgenis    文件:WebAppConfig.java   
/**
 * Configures Freemarker
 */
@Override
public FreeMarkerConfigurer freeMarkerConfigurer()
{
    FreeMarkerConfigurer result = super.freeMarkerConfigurer();
    // Look up unknown templates in the FreemarkerTemplate repository
    result.setPostTemplateLoaders(new RepositoryTemplateLoader(dataService));
    return result;
}
项目:molgenis    文件:MolgenisWebAppConfig.java   
/**
 * Configure freemarker. All freemarker templates should be on the classpath in a package called 'freemarker'
 */
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer()
{
    FreeMarkerConfigurer result = new FreeMarkerConfigurer()
    {
        @Override
        protected void postProcessConfiguration(Configuration config) throws IOException, TemplateException
        {
            config.setObjectWrapper(new MolgenisFreemarkerObjectWrapper(VERSION_2_3_23));
        }
    };
    result.setPreferFileSystemAccess(false);
    result.setTemplateLoaderPath("classpath:/templates/");
    result.setDefaultEncoding("UTF-8");
    Properties freemarkerSettings = new Properties();
    freemarkerSettings.setProperty(Configuration.LOCALIZED_LOOKUP_KEY, Boolean.FALSE.toString());
    result.setFreemarkerSettings(freemarkerSettings);
    Map<String, Object> freemarkerVariables = Maps.newHashMap();
    freemarkerVariables.put("limit", new LimitMethod());
    freemarkerVariables.put("hasPermission", new HasPermissionDirective(permissionService));
    freemarkerVariables.put("notHasPermission", new NotHasPermissionDirective(permissionService));
    addFreemarkerVariables(freemarkerVariables);

    result.setFreemarkerVariables(freemarkerVariables);

    return result;
}
项目:brainbox    文件:WebConfig.java   
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setTemplateLoaderPath("classpath:/templates/");
    configurer.setDefaultEncoding("UTF-8");
    return configurer;
}
项目:mockserver    文件:WebMvcConfiguration.java   
@Bean
public FreeMarkerConfigurer freemarkerConfig() throws IOException, TemplateException {
    FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
    freeMarkerConfigurer.setConfiguration(new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_22) {{
        setTemplateLoader(new MultiTemplateLoader(
                new TemplateLoader[]{
                        new ClassTemplateLoader(FreeMarkerConfig.class, "/")
                }
        ));
        setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        setWhitespaceStripping(true);
    }});
    return freeMarkerConfigurer;
}
项目:github-cla-integration    文件:WebConfiguration.java   
@Bean
FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setTemplateLoaderPath("classpath:META-INF/freemarker");

    return configurer;
}