在mapper中传入数组或集合类,使用foreach标签遍历出其中的值与SQL语句拼接
JAVA dao层接口
public interface UserDao { public List getUsersByCollection(Collection collection);}
mapper文件
测试
@Testpublic void getUsersByCollection() { Collection collection = new ArrayList(); collection.add(1); collection.add(3); collection.add(5); List users = userDao.getUsersByCollection(collection); System.out.println(users);}