传的参数是一个数组, Long[] ids
后台错误写法
<delete id="deleteById"> delete from table where id in <foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete>
正确写法
<delete id="deleteById"> delete from table where id in <foreach collection="array" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete>
当mybatis传入参数为list集合的时候;mybatis会自动把其封装为一个map;会以“list”作为key;每个元素的值作为value;格式为 Map<"list",value>
当mybatis传入参数为数组的时候mybatis会自动把其封装为一个map;会以“array”作为key;每个元素的值作为value;格式为Map<"array",value>