Mybatis 参数List查询
2019-03-14 本文已影响0人
Jin110
1)java代码
Map<String, Object> param = new HashMap<>();
List<Integer> idList = new ArrayList<>();
param.put("arr", idList);
2)mybatix.xml
SELECT * FROM table
WHERE 1 = 1
<if test="arr != null">
AND id IN
<foreach item="item" index="index" collection="arr" open="(" close=")" separator=",">
#{item}
</foreach>
</if>