日期:2014-05-17 浏览次数:20730 次
<table ct:if="users != null && users.size > 0" border="1"> <tr ct:for="user : users"> <td><span ct:out="for.index + 1">1</span></td> <td><span ct:out="user.name">james</span></td> <td><span ct:out="user.coins">2.00</span></td> </tr> </table>
$if{users != null && users.size > 0} <table border="1"> $for{user : users} <tr> <td>$out{for.index + 1}<span>1</span>$end</td> <td>$out{user.name}}<span>james</span>$end</td> <td>$out{user.coins}}<span>2.00</span>$end</td> </tr> $end </table> $end
// Tag外套内容封装 public final class Coat { private final String before; private final String after; public Coat(String before, String after) { this.before = before; this.after = after; } public String getBefore() { return before; } public String getAfter() { return after; } } public interface AttributeCoatHandler { // 解析器在遇到相应属性时, 回调此接口 // 并将返回的Coat中的before和after内容添加到Tag两端 Coat handleAttribute(String attrName, String attrValue); } // 注册指定名称空间的属性处理器 TagCoatContext.registerAttributeCoatHandler(String namespace, AttributeCoatHandler handler);