Package com.xxl.tool.freemarker
Class FtlTool
java.lang.Object
com.xxl.tool.freemarker.FtlTool
freemarker tool
- Author:
- xuxueli 2018-05-02 19:56:00
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic freemarker.template.TemplateHashModelgenerateStaticModel(String packageName) 生成 freemarker 自定义方法static voidinit(freemarker.template.Configuration freemarkerConfig) init with specified freemarkerConfigstatic voidinit with propstatic StringprocessString(freemarker.template.Configuration freemarkerConfig, String templateName, Map<String, Object> params) process and generate String with specified freemarkerConfigstatic StringprocessString(String templateName, Map<String, Object> params) process and generate String with default freemarkerConfigstatic StringprocessTemplateIntoString(freemarker.template.Template template, Object model) process Template Into String
-
Constructor Details
-
FtlTool
public FtlTool()
-
-
Method Details
-
init
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:
IOExceptionfreemarker.template.TemplateException
-
processString
public static String processString(String templateName, Map<String, Object> params) throws IOException, freemarker.template.TemplateExceptionprocess and generate String with default freemarkerConfig- Parameters:
templateName-params-- Returns:
- Throws:
IOExceptionfreemarker.template.TemplateException
-
processString
public static String processString(freemarker.template.Configuration freemarkerConfig, String templateName, Map<String, Object> params) throws IOException, freemarker.template.TemplateExceptionprocess and generate String with specified freemarkerConfig- Parameters:
freemarkerConfig-templateName-params-- Returns:
- Throws:
IOExceptionfreemarker.template.TemplateException
-
generateStaticModel
生成 freemarker 自定义方法// 自定义方法包装; TemplateHashModel model = FreemarkerTool.generateStaticModel(I18nUtil.class.getName()) // 注入SpringMVC响应对象,逻辑运营在 “AsyncHandlerInterceptor.postHandle” 中; modelAndView.addObject("I18nUtil", model);- Parameters:
packageName-- Returns:
-