Configuration config =
new Configuration();
try { config.setDirectoryForTemplateLoading(
new File(
"bin/template"));
config.setDefaultEncoding("UTF-8"); Template template = config.getTemplate(
"add.jsp"); template.setEncoding(
"UTF-8"); config.setObjectWrapper(
new DefaultObjectWrapper()); Map<String, Object> map =
new HashMap<String, Object>(); map.put(
"className",
"className"); map.put(
"columnDescribe",
"columnDescribe"); map.put(
"columnName",
"columnName"); map.put(
"action",
"add"); map.put(
"title",
"title"); List<String> columns =
new ArrayList<String>(); columns.add(
"a"); columns.add(
"a"); columns.add(
"a"); columns.add(
"a"); map.put(
"columns", columns); Writer out =
new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(
"test.jsp"),
"UTF-8")); template.process(map, out); out.flush(); }
catch (Exception e) { e.printStackTrace(); }