<!-- 7.2 foreach(循环List<String>参数) - 作为where中in的条件 -->  
<select >  
        #{classIdList}  
     </foreach>  
</select>  
  

测试代码,查询学生中,在20000001、20000002这两个班级的学生:

Java代码 mybatis如何传入一个list参数 
@Test  
public void test7_2_foreach() {  
    ArrayList<String> classIdList = new ArrayList<String>();  
    classIdList.add("20000001");  
    classIdList.add("20000002");  
    List<StudentEntity> list = this.dynamicSqlMapper.getStudentListByClassIds_foreach_list(classIdList);  
    for (StudentEntity e : list) {  
        System.out.println(e.toString());  
    }  
}  

相关文章:

  • 2021-06-03
  • 2021-11-25
  • 2021-04-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
相关资源
相似解决方案