こんにちは、StringTemplate バージョン 3.2.1 と Java を使用しています。
ArrayList を Stringtemplate に渡していますが、それを取得していません。値の数に応じて配列を反復処理したい。
ArrayList<Integer> test = new ArrayList<Integer>();
test.add(12334435);
test.add(12334436);
...
StringTemplate sysProperties = new StringTemplateGroup("group","locationOfTemplate").getInstanceOf("templateName");
sysProperties.setAttribute("system", "test");
(これはうまくいきます)
sysProperties.setAttribute("n", test);
(しかし、渡されたarrayListを無視しているようです。そのため、配列内の値の数に応じて、xmlを動的に構築したいと考えています)
ファイルの StringTemplate:
<data>
$if(test)$
$test:{ n |
<value>
<string>$n$</string>
</value>}$
$endif$
</data>
これについての助けをいただければ幸いです。前もって感謝します。