在MyBatis中,可以使用IN关键字来将数组参数转换为列表。例如,如果有一个ids数组作为参数,可以使用以下方式将其转换为MyBatis接受的IN列表:
<select id="selectByIds" parameterType="java.util.List" resultType="YourResultType"> SELECT * FROM your_table WHERE id IN <foreach collection="list" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> List<Integer> idsList = Arrays.asList(ids); yourMapper.selectByIds(idsList); 这样就可以将数组参数转换为MyBatis接受的IN列表形式。