public String proessPageContent() { try { String name = this.clazz.getSimpleName(); pageExt = pageExt == null ? ".html" : pageExt; name = this.pageName == null ? name : pageName; cfg = this.getCfg(); cfg.setNumberFormat("0.##"); Template temp = cfg.getTemplate(name + pageExt); ByteOutputStream stream = new ByteOutputStream(); Writer out = new OutputStreamWriter(stream); temp.process(data, out); out.flush(); String content = stream.toString(); if (wrapPath) { // System.out.println("before:---------------------------"); // System.out.println(content); content = EopUtil.wrapjavascript(content, this.getResPath()); content = EopUtil.wrapcss(content, getResPath()); // System.out.println("after:---------------------------"); // System.out.println(content); } // content= StringUtil.compressHtml(content); return content; } catch (IOException e) { e.printStackTrace(); } catch (TemplateException e) { e.printStackTrace(); } return "widget processor error"; }
public static void main(String[] args) throws IOException, TemplateException { Configuration cfg = FreeMarkerUtil.getFolderCfg( "D:/workspace/eopnew/eop/WebContent/WEB-INF/classes/com/enation/javashop/core/widget/goodscat"); Template temp = cfg.getTemplate("GoodsCat.html"); ByteOutputStream stream = new ByteOutputStream(); Writer out = new OutputStreamWriter(stream, "UTF-8"); temp.process(new HashMap(), out); out.flush(); String html = stream.toString(); System.out.println(html); }
public static void test() { Configuration cfg; try { cfg = FreeMarkerUtil.getFolderCfg( "D:/workspace/eopnew/eop/WebContent/WEB-INF/classes/com/enation/javashop/core/widget/goodscat"); Template temp = cfg.getTemplate("GoodsCat.html"); ByteOutputStream stream = new ByteOutputStream(); Writer out = new OutputStreamWriter(stream, "UTF-8"); temp.process(new HashMap(), out); out.flush(); String html = stream.toString(); System.out.println("+++++++++" + html); } catch (IOException e) { e.printStackTrace(); } catch (TemplateException e) { e.printStackTrace(); } }