1、foreach 中集合size如果为0 则不添不会添加open和 close
2、foreach 中如果集合为null 默认情况抛出异常异常,
3、可以在foreach种添加nullable为true,让集为null的时候不抛异常
<foreach nullable="true" item="item" index="index" collection="deptIds" open=" and t.dept_id in (" separator=" , " close=" ) ">
#{item}
</foreach>
4、可以在配置文件中添加nullableOnForEach,来设置foreach上的nullable的默认值
<setting name="nullableOnForEach" value="true" />
5、nullableOnForEach属性和nullable均在3.5.9及以上版本