鏈接原文:
https://www.cnblogs.com/yy3b2007com/p/10417242.html#autoid-1-0-0
個人用法:
我使用的是list對sql的in的傳參.後臺從前臺獲取傳來的id的字符串數組。後臺對傳來的字符串數組進行處理,將其放到方法參數列表中。
String[] sxxxid //此爲傳遞來的參數
List<String> sxxxidlist = Arrays.asList(sxxxid);
select * from 表名 where 條件
IN
<foreach item="sxxxid" index="index" collection="list" open="(" separator="," close=")">
#{sxxxid}
</foreach>
)
這樣就可以實現mybatis中in的用法了
使用字符串數組的時候
<foreach item="item" index="index" collection="ryzrzjxxVO.zfryxxIds" open="(" separator="," close=")">
#{item}
</foreach>