我是靠谱客的博主 文静手机,这篇文章主要介绍MyBatis 使用数组作为参数,现在分享给大家,希望可以做个参考。

踩坑记:在传递List<Integer> typeIds作为参数时,MyBatis foreach不能获取到参数,使用Integer[] typeIds就可以了。

主要代码:
1、接口

复制代码
1
2
List<Station> getList(@Param("typeIds") Integer[] typeIds);

2、xml文件

复制代码
1
2
3
4
5
6
<select id="getList" resultType="Station"> select id, `name`, lon, lat, city, county, town, is_native isNative, type, `describe` from stations where is_native in <foreach collection="typeIds" item="id" open="(" close=")" separator=",">#{id}</foreach> </select>

最后

以上就是文静手机最近收集整理的关于MyBatis 使用数组作为参数的全部内容,更多相关MyBatis内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(83)

评论列表共有 0 条评论

立即
投稿
返回
顶部