本文整理汇总了Java中org.apache.velocity.app.VelocityEngine.addProperty方法的典型用法代码示例。如果您正苦于以下问题:Java VelocityEngine.addProperty方法的具体用法?Java VelocityEngine.addProperty怎么用?Java VelocityEngine.addProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.velocity.app.VelocityEngine
的用法示例。
在下文中一共展示了VelocityEngine.addProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessVelocityEngine
import org.apache.velocity.app.VelocityEngine; //导入方法依赖的package包/类
/**
* Provides a ClasspathResourceLoader in addition to any default or user-defined
* loader in order to load the spring Velocity macros from the class path.
* @see org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
*/
@Override
protected void postProcessVelocityEngine(VelocityEngine velocityEngine) {
velocityEngine.setApplicationAttribute(ServletContext.class.getName(), this.servletContext);
velocityEngine.setProperty(
SPRING_MACRO_RESOURCE_LOADER_CLASS, ClasspathResourceLoader.class.getName());
velocityEngine.addProperty(
VelocityEngine.RESOURCE_LOADER, SPRING_MACRO_RESOURCE_LOADER_NAME);
velocityEngine.addProperty(
VelocityEngine.VM_LIBRARY, SPRING_MACRO_LIBRARY);
if (logger.isInfoEnabled()) {
logger.info("ClasspathResourceLoader with name '" + SPRING_MACRO_RESOURCE_LOADER_NAME +
"' added to configured VelocityEngine");
}
}
示例2: sqlTemplateService
import org.apache.velocity.app.VelocityEngine; //导入方法依赖的package包/类
public static String sqlTemplateService(String template,Map paramMap,List placeList){
VelocityEngine ve = new VelocityEngine();
ve.addProperty("userdirective", "com.minxin.micro.template.vext.MicroSqlReplace");
ve.init();
VelocityContext context = new VelocityContext();
context.put("param", paramMap);
context.put("placeList", placeList);
StringWriter writer = new StringWriter();
ve.evaluate(context, writer, "", template);
return writer.toString();
}
示例3: VelocityTemplate
import org.apache.velocity.app.VelocityEngine; //导入方法依赖的package包/类
/**
* Create an instance.
* @param header The fixed header
* @param footer The fixed footer
* @param row The template for the rows
*/
public VelocityTemplate(String header, String footer, String row) {
super(header, footer);
VelocityEngine engine = new VelocityEngine();
engine.setProperty(Velocity.RESOURCE_LOADER, "string");
engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
engine.addProperty("string.resource.loader.repository.static", "false");
engine.init();
StringResourceRepository repository = (StringResourceRepository)engine.getApplicationAttribute(
StringResourceLoader.REPOSITORY_NAME_DEFAULT);
repository.putStringResource(TEMPLATE_NAME, row);
template = engine.getTemplate(TEMPLATE_NAME);
}
示例4: setUp
import org.apache.velocity.app.VelocityEngine; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
game = new Game();
game.setName("UnitTest Game");
nf = new NotificationFormatter();
nf.setBaseUrl("http://trivolous.com/unittest/");
VelocityEngine ve = new VelocityEngine();
ve.addProperty("resource.loader", "class");
ve.addProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
nf.setVelocityEngine(ve);
}
示例5: MailTemplateVelocity
import org.apache.velocity.app.VelocityEngine; //导入方法依赖的package包/类
public MailTemplateVelocity(Mail mail) throws ResourceNotFoundException {
String arquivoTemplate = mail.getTemplate();
VelocityEngine engine = new VelocityEngine();
engine.addProperty("resource.loader", "class");
engine.addProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
engine.init();
Template template = engine.getTemplate(arquivoTemplate);
NumberTool numberTool = new NumberTool();
assert (numberTool != null);
VelocityContext context = new VelocityContext(mail.getParametros());
context.put("numberTool", numberTool);
context.put("locale", Locale.getDefault());
StringWriter writer = new StringWriter();
template.merge(context, writer);
htmlContent = writer.toString();
}