在我的 Velocity 模板(.vm 文件)中,我如何循环遍历存在的所有变量或属性VelocityContext
?参考下面的代码,我希望模板写出在上下文中传递的所有水果的名称和数量。
Map<String, Object> attribues = ...;
attribues.put("apple", "5");
attribues.put("banana", "2");
attribues.put("orange", "3");
VelocityContext velocityContext = new VelocityContext(attribues);
velocityEngine.mergeTemplate(templateLocation, encoding, velocityContext, writer);