具体格式是以下

属性separator 为逗号

前段传过来的myList 参数是list集合

 <if test="myList != null">
            AND dm in
            <foreach collection="myList " item="item" open="(" separator="," close=")">
                #{item , jdbcType=VARCHAR }
            </foreach>
        </if>

最后渲染为sql语句为

AND dm in ( '03' , '04')

属性separator 为or

前段传过来的myList 参数是list集合

    <if test="myList != null">
            AND
            <foreach collection="myList " index="index" item="item" open="(" separator="or" close=")">
                dm  = #{item , jdbcType=VARCHAR }
            </foreach>
        </if>

最后渲染为sql语句为

AND ( dm  = '01'or dm   = '02' or dm   = '03')