0

こんにちは、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>

これについての助けをいただければ幸いです。前もって感謝します。

4

1 に答える 1

0

ST3でST4構文を使用しているようです

$test:{ **n|**<-- You should use 'it' attribute to iterate - "The iterated it atribute is
set automatically" 

ソース

于 2013-07-02T13:51:43.383 に答える