本文整理了Java中org.apache.velocity.app.Velocity.mergeTemplate()
方法的一些代码示例,展示了Velocity.mergeTemplate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Velocity.mergeTemplate()
方法的具体详情如下:
包路径:org.apache.velocity.app.Velocity
类名称:Velocity
方法名:mergeTemplate
[英]merges a template and puts the rendered stream into the writer
[中]合并模板并将渲染流放入编写器
代码示例来源:origin: NotBadPad/easy-httpserver
/**
* 渲染Velocity模板
* @param path
* @param map
*/
public static String mergeTemplate(String path, Map<String, Object> map) throws IOException {
VelocityContext vc = new VelocityContext();
if (null != map) {
for (String key : map.keySet()) {
vc.put(key, map.get(key));
}
}
StringWriter w = new StringWriter();
Velocity.mergeTemplate(path, "utf-8", vc, w);
String content = w.toString();
w.close();
return content;
}
}
代码示例来源:origin: velocity/velocity-dep
/**
* merges a template and puts the rendered stream into the writer
*
* @param templateName name of template to be used in merge
* @param context filled context to be used in merge
* @param writer writer to write template into
*
* @return true if successful, false otherwise. Errors
* logged to velocity log.
* @deprecated Use
* {@link #mergeTemplate( String templateName, String encoding,
* Context context, Writer writer )}
*/
public static boolean mergeTemplate( String templateName,
Context context, Writer writer )
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
{
return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
context, writer );
}
代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity
/**
* Merges a template and puts the rendered stream into the writer.
* The default encoding that Velocity uses to read template files is defined in
* the property input.encoding and defaults to ISO-8859-1.
*
* @param templateName name of template to be used in merge
* @param context filled context to be used in merge
* @param writer writer to write template into
*
* @return true if successful, false otherwise. Errors
* logged to velocity log.
* @deprecated Use
* {@link #mergeTemplate( String templateName, String encoding,
* Context context, Writer writer )}
* @throws ParseErrorException The template could not be parsed.
* @throws MethodInvocationException A method on a context object could not be invoked.
* @throws ResourceNotFoundException A referenced resource could not be loaded.
* @throws Exception Any other exception.
*/
public static boolean mergeTemplate( String templateName,
Context context, Writer writer )
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception
{
return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
context, writer );
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity
/**
* Merges a template and puts the rendered stream into the writer.
* The default encoding that Velocity uses to read template files is defined in
* the property input.encoding and defaults to ISO-8859-1.
*
* @param templateName name of template to be used in merge
* @param context filled context to be used in merge
* @param writer writer to write template into
*
* @return true if successful, false otherwise. Errors
* logged to velocity log.
* @deprecated Use
* {@link #mergeTemplate( String templateName, String encoding,
* Context context, Writer writer )}
* @throws ParseErrorException The template could not be parsed.
* @throws MethodInvocationException A method on a context object could not be invoked.
* @throws ResourceNotFoundException A referenced resource could not be loaded.
*/
public static boolean mergeTemplate( String templateName,
Context context, Writer writer )
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException
{
return mergeTemplate( templateName, RuntimeSingleton.getString(INPUT_ENCODING,ENCODING_DEFAULT),
context, writer );
}
代码示例来源:origin: apache/wicket
if (!Velocity.mergeTemplate(templateName, encoding, ctx, writer))
代码示例来源:origin: com.legsem.legstar/legstar-codegen
Velocity.mergeTemplate(templateName, "UTF-8", context, w);
Writer out = null;
try {
代码示例来源:origin: org.apache.wicket/wicket-velocity
if (!Velocity.mergeTemplate(templateName, encoding, ctx, writer))
内容来源于网络,如有侵权,请联系作者删除!