target is null for method size错误解决
当使用mybatis的forEach动态SQL时注意:
判断添加的顺序一定要非空在前,大小在非空的后面
<if test="collection != null and collection.size() > 0 ">
and xx in
<foreach collection="collection" close=")" index="index" open="(" item="item" separator=",">
#{item}
</foreach>
</if>
而不是下面的条件的写法:
<if test="collection.size() > 0 and collection != null">
and xx in
<foreach collection="collection" close=")" index="index" open="(" item="item" separator=",">
#{item}
</foreach>
</if>