package com.axt.test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class FreeMarker {
public static void main(String[] args) {
// 通过Freemaker的Configuration读取相应的ftl
Configuration cfg = new Configuration();
try {
// 设定去哪里读取相应的ftl模板文件
cfg.setClassForTemplateLoading(this.getClass(), "/ftl");
// 在模板文件目录中找到名称为name的文件
Template template = cfg.getTemplate(name);
// Build the data-model
Map<String, Object> data = new HashMap<String, Object>();
data.put("message", "Hello World!");
//List parsing
// <td width="33%">检测单位:${reporthead.inspectionunit}</td>
// <td width="33%">检测人:${reporthead.username}</td>
// <td width="33%">被检测单位:${reporthead.detectionunit}</td>
Persion1 persion = new Persion1();
persion.setName("1");
data.put("reporthead", persion);
data.put("datareportName", "任务漏洞详述");
// Console output
Writer out = new OutputStreamWriter(System.out);
template.process(data, out);
out.flush();
// File output
String path = "D:\\workspace\\leakscan\\WebRoot\\upload\\ReportExp" + "\\"+ "HTML" + "\\2-2css.html" ;
Writer file = new FileWriter (new File(path));
template.process(data, file);
file.flush();
file.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
}
}
class Persion1{
public String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class FreeMarker {
public static void main(String[] args) {
// 通过Freemaker的Configuration读取相应的ftl
Configuration cfg = new Configuration();
try {
// 设定去哪里读取相应的ftl模板文件
cfg.setClassForTemplateLoading(this.getClass(), "/ftl");
// 在模板文件目录中找到名称为name的文件
Template template = cfg.getTemplate(name);
// Build the data-model
Map<String, Object> data = new HashMap<String, Object>();
data.put("message", "Hello World!");
//List parsing
// <td width="33%">检测单位:${reporthead.inspectionunit}</td>
// <td width="33%">检测人:${reporthead.username}</td>
// <td width="33%">被检测单位:${reporthead.detectionunit}</td>
Persion1 persion = new Persion1();
persion.setName("1");
data.put("reporthead", persion);
data.put("datareportName", "任务漏洞详述");
// Console output
Writer out = new OutputStreamWriter(System.out);
template.process(data, out);
out.flush();
// File output
String path = "D:\\workspace\\leakscan\\WebRoot\\upload\\ReportExp" + "\\"+ "HTML" + "\\2-2css.html" ;
Writer file = new FileWriter (new File(path));
template.process(data, file);
file.flush();
file.close();
} catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
}
}
class Persion1{
public String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}