template.process(root, out)的用法(shiro项目中来的九)

假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html1 Writer out = new BufferedWriter(new OutputS...
摘要由CSDN通过智能技术生成
 
  

假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过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 /** 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值