0
我试图让简单的例子来工作,这里是示例代码.STG文件StringTemplate的使用的listItem
group list-demo;
htmListExample(xmen) ::= <<
Example 5:
<html>
<body>
<h1>Original X-Men</h1>
<ul>
$xmen:listItem()$
</ul>
</body>
</html>
>>
listItem() ::= <<
<li>$it$</li>
>>
我的Java代码:
STGroup group = new STGroupFile("/myTemplate2.stg",'$','$');
ST template = group.getInstanceOf("htmListExample");
List<String> xmen = Arrays.asList("Jean Gray", "Cyclops");
template.add("xmen", xmen);
System.out.println(template.render().toString());
和输出:
context [/htmListExample] 6:18 passed 1 arg(s) to template /listItem with 0 declared arg(s)
context [/htmListExample] 6:13 passed 1 arg(s) to template /listItem with 0 declared arg(s)
context [/htmListExample] 6:13 passed 1 arg(s) to template /listItem with 0 declared arg(s)
context [/htmListExample /listItem] 2:5 attribute it isn't defined
context [/htmListExample /listItem] 2:5 attribute it isn't defined
Example 5:
<html>
<body>
<h1>Original X-Men</h1>
<ul>
<li></li>
<li></li>
</ul>
</body>
</html>
任何人都可以阐明为什么listItem()不被识别?我正在使用ST-4.0.7.jar。
感谢
是的。而已。我想我正在查找一个老例子。谢谢。 – user2635921