Class FtlTool

java.lang.Object
com.xxl.tool.freemarker.FtlTool

public class FtlTool extends Object
freemarker tool
Author:
xuxueli 2018-05-02 19:56:00
  • Constructor Details

    • FtlTool

      public FtlTool()
  • Method Details

    • init

      public static void init(String templatePath)
      init with prop
      Parameters:
      templatePath -
    • init

      public static void init(freemarker.template.Configuration freemarkerConfig)
      init with specified freemarkerConfig
      Parameters:
      freemarkerConfig -
    • processTemplateIntoString

      public static String processTemplateIntoString(freemarker.template.Template template, Object model) throws IOException, freemarker.template.TemplateException
      process Template Into String
      Parameters:
      template -
      model -
      Returns:
      Throws:
      IOException
      freemarker.template.TemplateException
    • processString

      public static String processString(String templateName, Map<String,Object> params) throws IOException, freemarker.template.TemplateException
      process and generate String with default freemarkerConfig
      Parameters:
      templateName -
      params -
      Returns:
      Throws:
      IOException
      freemarker.template.TemplateException
    • processString

      public static String processString(freemarker.template.Configuration freemarkerConfig, String templateName, Map<String,Object> params) throws IOException, freemarker.template.TemplateException
      process and generate String with specified freemarkerConfig
      Parameters:
      freemarkerConfig -
      templateName -
      params -
      Returns:
      Throws:
      IOException
      freemarker.template.TemplateException
    • generateStaticModel

      public static freemarker.template.TemplateHashModel generateStaticModel(String packageName)
      生成 freemarker 自定义方法
           // 自定义方法包装;
           TemplateHashModel model = FreemarkerTool.generateStaticModel(I18nUtil.class.getName())
           // 注入SpringMVC响应对象,逻辑运营在 “AsyncHandlerInterceptor.postHandle” 中;
           modelAndView.addObject("I18nUtil", model);
       
      Parameters:
      packageName -
      Returns: