假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html
1 Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8")); 2 Template template = getTemplate(ftlName, ftlPath); 3 template.process(root, out);
1 public static Template getTemplate(String ftlName, String ftlPath) throws Exception{ 2 try { 3 Configuration cfg = new Configuration(); //通过Freemaker的Configuration读取相应的ftl 4 cfg.setEncoding(Locale.CHINA, "utf-8"); 5 cfg.setDirectoryForTemplateLoading(new File(PathUtil.getClassResources()+"/ftl/"+ftlPath)); //设定去哪里读取相应的ftl模板文件 6 Template temp = cfg.getTemplate(ftlName); //在模板文件目录中找到名称为name的文件 7 return temp; 8 } catch (IOException e) { 9 e.printStackTrace(); 10 } 11 return null; 12 }
template 就是获取的模板
1 package com.fh.controller.${packageName}.${objectNameLower}; 2 3 import java.io.PrintWriter; 4 import java.text.DateFormat; 5 import java.text.SimpleDateFormat; 6 import java.util.ArrayList; 7 import java.util.Date; 8 import java.util.HashMap; 9 import java.util.List; 10 import java.util.Map; 11 import javax.annotation.Resource; 12 import org.springframework.beans.propertyeditors.CustomDateEditor; 13 import org.springframework.stereotype.Controller; 14 import org.springframework.web.bind.WebDataBinder; 15 import org.springframework.web.bind.annotation.InitBinder; 16 import org.springframework.web.bind.annotation.RequestMapping; 17 import org.springframework.web.bind.annotation.ResponseBody; 18 import org.springframework.web.servlet.ModelAndView; 19 import com.fh.controller.base.BaseController; 20 import com.fh.entity.Page; 21 import com.fh.util.AppUtil; 22 import com.fh.util.ObjectExcelView; 23 import com.fh.util.PageData; 24 import com.fh.util.Jurisdiction; 25 import com.fh.util.Tools; 26 import com.fh.service.${packageName}.${objectNameLower}.${objectName}Manager; 27 28 /**