在使用mybatis的時候,mapper只傳了一個list集合參數,結果就報錯:
Parameter 'roleIds' not found. Available parameters are [collection, list]] with root cause
就是說這個參數沒有找到, 這個時候可以用@Param指定參數就行了。
mapper
import org.apache.ibatis.annotations.Param;
int deleteByIds(@Param("roleIds") List<String> roleIds);
mapper.xml
<delete id="deleteByIds" parameterType="java.util.List">
delete from role where id in
<foreach collection="roleIds" item="item" separator="," open="(" close=")" >
#{item, jdbcType=INTEGER}
</foreach>
</delete>