如果数组不为空,如何使用 StringTemplate 检查?
下面的例子不起作用:
<if(teams.length > 0)>
<ul>
<teams:{team | <li><team></li> }>
</ul>
<endif>
其他(不工作)例如:
String content = "<if(teams)>list: <teams;separator=\", \"><endif>";
ST template = new ST(content);
template.add("teams", new Long[]{123L, 124L});
System.out.println(template.render());
System.out.println("--------");
content = "<if(teams)>list: <teams;separator=\", \"><endif>";
template = new ST(content);
template.add("teams", new Long[]{});
System.out.println(template.render());
输出:
list: 123, 124
--------
list: