mybatis if test判断 list不为空

mapper传递的参数为如下图中list集合时
在这里插入图片描述
在mapper.xml中用if test 判断此集合是否为空的写法如下:

<if test="costsIds != null and costsIds.size()!=0 ">
      and  standard_costs_id in
        <foreach item="item" collection="costsIds" separator="," open="(" close=")">
           #{item}
        </foreach>
</if>

你可能感兴趣的:(mybatis,xml,java)