public class FreemarkerUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static FreemarkerUtils |
build(Class<?> sourceClass,
String templatePath)
Build freemarker util instance by source class and template path
|
String |
generate(Object model)
Generate to string(invoke this method must after setTemplate)
|
void |
generate(Object model,
BufferedWriter writer)
Generate to buffered writer(invoke this method must after setTemplate)
|
void |
generate(Object model,
File file)
Generate to file(invoke this method must after setTemplate)
|
void |
generate(Object model,
OutputStream outputStream)
Generate to output stream(invoke this method must after setTemplate)
|
FreemarkerUtils |
setTemplate(String templateName)
Set template by name
|
public static FreemarkerUtils build(Class<?> sourceClass, String templatePath)
sourceClass - the class that uses this utiltemplatePath - the template pathpublic FreemarkerUtils setTemplate(String templateName)
templateName - the template namepublic String generate(Object model)
model - the holder of the variables visible from the template (name-value pairs); usually a
Map<String, Object> or a JavaBean (where the JavaBean properties will be the variables)public void generate(Object model, File file)
model - the holder of the variables visible from the template (name-value pairs); usually a
Map<String, Object> or a JavaBean (where the JavaBean properties will be the variables)file - the target filepublic void generate(Object model, OutputStream outputStream)
model - the holder of the variables visible from the template (name-value pairs); usually a
Map<String, Object> or a JavaBean (where the JavaBean properties will be the variables)outputStream - the target output streampublic void generate(Object model, BufferedWriter writer)
model - the holder of the variables visible from the template (name-value pairs); usually a
Map<String, Object> or a JavaBean (where the JavaBean properties will be the variables)writer - the target buffered writerCopyright © 2019. All rights reserved.