我正在尝试使简单的示例正常工作,这是示例代码 .stg 文件
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。
谢谢