コード例 #1
0
 @Bean
 public FreeMarkerConfigurer freemarkerConfig() {
   FreeMarkerConfigurer result =
       new org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer();
   result.setTemplateLoaderPath("/WEB-INF/views/ftl/");
   return result;
 }
コード例 #2
0
  protected static FreeMarkerConfigurer getFreeMarkerConfigurer(
      ApplicationContext applicationContext) {
    Map<String, Object> freemarkerVariables = new HashMap<String, Object>();
    freemarkerVariables.put("xml_escape", "fmXmlEscape");
    freemarkerVariables.put("replaceParam", new ReplaceParamTemplateMethod());
    freemarkerVariables.put("timeAgo", new TimeAgoTemplateMethod());
    freemarkerVariables.putAll(listTemplateMethod(applicationContext));

    Properties freemarkerSettings = new Properties();
    freemarkerSettings.put("template_update_delay", "1");
    freemarkerSettings.put("defaultEncoding", "UTF-8");

    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setTemplateLoaderPath("/WEB-INF/ftl/");
    configurer.setFreemarkerVariables(freemarkerVariables);
    configurer.setFreemarkerSettings(freemarkerSettings);

    try {
      configurer.afterPropertiesSet();
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage(), e);
    } catch (TemplateException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    return configurer;
  }
コード例 #3
0
ファイル: WebAppConfig.java プロジェクト: shesketh/molgenis
  /**
   * Configure freemarker. All freemarker templates should be on the classpath in a package called
   * 'freemarker'
   */
  @Bean
  public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer result = new FreeMarkerConfigurer();
    result.setPreferFileSystemAccess(false);
    result.setTemplateLoaderPath("classpath:/templates/");

    return result;
  }
コード例 #4
0
ファイル: WebConfig.java プロジェクト: Antowka/Stock-Manager
 @Bean(name = "freemarkerConfig")
 public FreeMarkerConfigurer freemarkerConfig() {
   FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
   configurer.setTemplateLoaderPath("/WEB-INF/templates/");
   Map<String, Object> map = new HashMap<>();
   map.put("xml_escape", new XmlEscape());
   configurer.setFreemarkerVariables(map);
   return configurer;
 }
コード例 #5
0
  @Bean
  public FreeMarkerConfigurer freemarkerConfig() {
    FreeMarkerConfigurer freemarkerConfig = new FreeMarkerConfigurer();
    freemarkerConfig.setTemplateLoaderPath("classpath:/templates");
    freemarkerConfig.setDefaultEncoding("UTF-8");

    Map<String, Object> freemarkerVariables = new HashMap<>();
    freemarkerVariables.put("layout", freemarkerLayoutDirectives());

    freemarkerConfig.setFreemarkerVariables(freemarkerVariables);
    return freemarkerConfig;
  }
コード例 #6
0
ファイル: WebConfig.java プロジェクト: laowoof/zaqSmartHome
 /** * 整合freemarket */
 @Bean
 public FreeMarkerConfig freeMarkerConfig() {
   FreeMarkerConfigurer freeMarkerConfig = new FreeMarkerConfigurer();
   freeMarkerConfig.setTemplateLoaderPath("classpath:/view/");
   Properties settings = new Properties();
   settings.setProperty("template_update_delay", "1");
   settings.setProperty("defaultEncoding", "utf-8");
   settings.setProperty("url_escaping_charset", "utf-8");
   settings.setProperty("locale", "zh_CN");
   freeMarkerConfig.setFreemarkerSettings(settings);
   return freeMarkerConfig;
 }
コード例 #7
0
 protected String buildText(JobExecution job) {
   Map<String, Object> result = getExecutionResult(job);
   try {
     fmConfg.setTemplateLoaderPath(config.getProperty("batch.freemarkDir"));
     Template t = fmConfg.getConfiguration().getTemplate(messageTemplate);
     return FreeMarkerTemplateUtils.processTemplateIntoString(t, result);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return new StringBuffer("<html><body>")
       .append(result.toString().replace(",", ",<br/>"))
       .append("</body></html>")
       .toString();
 }