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>:表示如果循环结束,则不加",".如果不加后面有会多一个",".

或者直接

packid in (:packids)

原文地址:https://www.cnblogs.com/nizuimeiabc1/p/6051711.html