Package freemarker.template

Examples of freemarker.template.Template.process()


      cfg.setObjectWrapper(new DefaultObjectWrapper());
      cfg.setTemplateUpdateDelay(0);
      Template temp = new Template(name, new InputStreamReader(src), cfg);
      final ByteArrayOutputStream bout = new ByteArrayOutputStream();
      Writer out = new OutputStreamWriter(bout);
      temp.process(renderContext, out);
      out.flush();
      merged = new DataHandler(new DataSource() {
        public InputStream getInputStream() throws IOException {
          return new ByteArrayInputStream(bout.toByteArray());
        }
View Full Code Here


    StringWriter writer = new StringWriter();
    //往上下文中填入数据
    Map context = new HashMap();
    context.put("ctx", result);
    context.put("xctx",session.getAttribute(HtmlResponseWriter.OPTION_KEY));
    template.process(context, writer);

    //输出到用户端
    writer.toString();
    out.write(writer.toString().getBytes());
  }
View Full Code Here

            "@test1@");
        templateObjects.put(
            "test2",
            "@test2@");

        template.process(
            templateObjects,
            writer);
        assertEquals(
            "@test1@@test2@",
            writer.getBuffer().toString());
View Full Code Here

        {
            templateObjects = new HashMap();
        }

        // - merge data model with template
        template.process(templateObjects, output);
    }

    /**
     * Template loader which accesses the context classloader because otherwise
     * templates will not be found properly in a multi-classloader environment.
View Full Code Here

            }

            final StringWriter output = new StringWriter();

            // - merge data model with template
            template.process(templateObjects, output);

            return output.toString();
        }
        catch (final Throwable throwable)
        {
View Full Code Here

        //TODO
        //template.process内部会自动调用writer.flush,
        //如果在输出ftl文件后又接着输出jsp,那么jsp会出异常:
        //java.lang.IllegalStateException: Cannot create a session after the response has been committed
        //因为调用writer.flush会导致响应头会被提交
        template.process(root, writer);

        //writer.flush();
        //writer.close();
      }
    } catch (Throwable t) {
View Full Code Here

            // Give subclasses a chance to hook into preprocessing
            if (preTemplateProcess(request, response, template, model)) {
                try {
                    // Process the template
                    template.process(model, response.getWriter());
                } finally {
                    // Give subclasses a chance to hook into postprocessing
                    postTemplateProcess(request, response, template, model);
                }
            }
View Full Code Here

        SimpleHash model = new SimpleHash();
        model.put("document", new NodeListModel(document));
        FileReader fr = new FileReader(args[0]);
        Template template = new Template(args[0], fr);
        Writer w = new java.io.OutputStreamWriter(System.out);
        template.process(model, w);
        w.flush();
        w.close();
    }

    private static final class AttributeXMLOutputter extends XMLOutputter {
View Full Code Here

        if (view.getContentType() != null){
            response.setContentType(view.getContentType());
        }
       
        Template t = cfg.getTemplate(path, request.getLocale());
        t.process(view.getAttributes(), response.getWriter());
    }
}
View Full Code Here

        {
            OutputStream stream = toFile ? new BufferedOutputStream(new FileOutputStream(f)) : nullStream;
            Writer writer = new OutputStreamWriter(stream, "UTF-8");
            try
            {
                template.process(h, writer);
            }
            finally
            {
                writer.close();
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.