首页 > 代码库 > freemarker在xml文件中遍历list数据

freemarker在xml文件中遍历list数据

delete
   from pub_channelpackage
   where channelcode = :channelcode
   and channeltype = :channeltype
   <#if packids?exists && packids??>
    and packid in (
          <#list packids as packageId>
     ${packageId}<#if packageId_has_next>,</#if>
    </#list>)
   </#if>

1.<#if packids?exists && packids??>:表示存在packids对象,并且对象的个数不为0;

2.<#list packids as packageId>:表示list中的成员变量为packageId;

3.<#if packageId_has_next>,</#if>:表示如果循环结束,则不加",".如果不加后面有会多一个",".

 

freemarker在xml文件中遍历list数据