傳的參數是一個數組, Long[] ids數組
後臺錯誤寫法mybatis
<delete id="deleteById"> delete from table where id in <foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete>
正確寫法spa
<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>code
當mybatis傳入參數爲數組的時候mybatis會自動把其封裝爲一個map;會以「array」做爲key;每一個元素的值做爲value;格式爲Map<"array",value>blog