MyBatis使用分页插件时并且查询条件包含foreach时,分页插件在执行count语句时会抛出异常,报参数为空异常。
一、报错代码
AND type IN <foreach collection="userTypes" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
二、报错信息
org.apache.ibatis.binding.BindingException: Parameter '__frch_item_0' not found. Available parameters are [userTypes, searchUserVo, param1, param2]
三、解决方法
AND type IN <foreach collection="userTypes" item="item" index="index" open="(" separator="," close=")">#{userTypes[${index}]}</foreach>