-1
JavaからST4条件を設定するには?StringTemplate 4からJavaから条件を設定
Exception in thread "main" java.lang.IllegalArgumentException: no such attribute: condition
at org.stringtemplate.v4.ST.add(ST.java:226)
at com.cupidocreative.main.StringTemplateSandboxMain.main(StringTemplateSandboxMain.java:16)
どのように設定するには:メインクラスは、私は、コードを実行したときただし、次のエラーが発生
public static void main(String[] args) {
final STGroup stGroup = new STGroupFile("exampleTemplate.stg", '$', '$');
stGroup.registerRenderer(String.class, new StringRenderer());
final ST templateExample = stGroup.getInstanceOf("templateExample");
templateExample.add("param", "Hello World");
templateExample.add("condition", true);
System.out.println(templateExample.render());
}
ですが
私はST4テンプレートに
templateExample(param) ::= <<
$if (condition)$
<ul><li>$param$ is true</li></ul>
$else$
<ul><li>$param$ is false</li></ul>
$endif$
>>
を以下しています私のJavaクラスから "条件"?事前ここ
http://stackoverflow.com/questions/20363331/stringtemplate-list-of-attributes-defined-for-a-given-template – user2494817