是否可以在以下情况下设置一个或多个 freemarker 变量:
<#assign test=pp.loadData('eval', '
a="test1";
b="test2";
return "test";')>
并可以访问 freemarker 脚本中的 a 和 b ?
是否可以在以下情况下设置一个或多个 freemarker 变量:
<#assign test=pp.loadData('eval', '
a="test1";
b="test2";
return "test";')>
并可以访问 freemarker 脚本中的 a 和 b ?
我想如果不编写 custom 就无法完成DataLoader
。我说“猜测”是因为我可能不知道BeanShell技巧。我能得到的最接近的是使用return this.namespace;
然后${test.getVariable('a')}
。这当然太冗长了。
更新:实际上,以下恐怖更接近:
<#assign test=pp.loadData('eval', '
a="test1";
b="test2";
// This should be factored out into a common function somehow
ns = this.namespace;
vars = new HashMap();
for (name : ns.getVariableNames()) {
vars.put(name, ns.getVariable(name));
}
return vars;
')>
${test.a}