{{parent.child.0.field}} 它没有解析,如果孩子是java.util.Set.如果它是一个java



>Template:

{{parent.child.0.field}}

上下文:

Mustache.Compiler c = Mustache.compiler();
Parent parentObj = new Parent();
Map<String, Object> ctx = Maps.newHashMap();
ctx.put("parent", parentObj);
c.compile(templateHtml).execute(ctx);

例外:

"exception" : "com.samskivert.mustache.MustacheException$Context",
  "message" : "Missing context for compound variable 'parent.child.0.field' on line 1. '0' was not found."

任何解决方法,无需将子项的模板或数据类型从"设置"更改为"列表"?

这是因为 Set 没有像 List 那样的 get(int index( 方法。

最新更新