比如:根据班级号查询学生的信息,参数是list

1、foreach的用法:【写法一】

<select id="getStudentListByClassId" resultMap="StudentResultList">

  select * form Student stu where stu.ClassId in

  <foreach collection="list" item="classList" open="(" separator="," close=")">

    #{classList}      [item是一个别名而已]

  </foreach>

</select>

2、criteria的用法:【写法二】

 <isNotEmpty property="criteria">
   <iterate property="criteria" conjunction="and" prepend="and"
 open="(" close=")">
    $criteria[].paramName$ $criteria[].arithmeticType$ #criteria[].paramValue#
 </iterate>

JAVA测试方法编写:(接口声明)

 public List<Student> getStudentListByClassId(List<String> classList);

测试代码,查询学生中在10000,10001这两个班级的学生:(具体实现方法)

  List<String> classList = new ArrayList<String>();

  classList.add("10000");

  classList.add("10001");

  List<Student> studentList = studentMapper.getStudentListByClassId(classList);

  for(Student stu:studentList){

    System.out.println(studentList.toString());

  }

最新文章

  1. JUnit 简介
  2. QQ拼音输入法 该到放弃的时候了
  3. shiro 简单的身份验证 案例
  4. iOS完整学习步骤
  5. jqurey click和blur执行时间冲突
  6. iOS开发数据库SQLite的使用
  7. 【转】错误日志ID8021来源BROWSER导致电脑死机
  8. windows下建立文件的换行符^M导致linux下的shell脚本执行错误的解决方式
  9. 由两代WIN8 Surface平板看微软心态
  10. WebView加载页面的两种方式——网络页面和本地页面
  11. CentOS6.5安装MySQL5.6
  12. 《代码整洁之道》(Clean Code)- 读书笔记
  13. java http 请求的工具类
  14. 关于xampp中无法启动mysql,Attempting to start MySQL service...的解决办法!!
  15. 转载 信号量 &lt;第六篇&gt;
  16. jvm内存模型中-栈,方法区,程序计数器是线程安全的
  17. Fiddler 简介
  18. Video to SDI Tx Bridge模块video_data(SD-SDI)处理过程
  19. android EditText设置弹出数字输入法键盘
  20. Python基础语法——(引号、字符串、长字符串、原始字符串、Unicode)

热门文章

  1. 第一次接触oracle
  2. java web中乱码的种类和一些解决方式
  3. 子类重用父类的功能super
  4. proxy配置
  5. Spring Batch Hello World
  6. 【GDOI 2016 Day1】第二题 最长公共子串
  7. LeetCode--078--子集(python)
  8. Linux学习-基于CentOS7的LAMP环境实现多虚拟主机
  9. 使用IDEA自动生成Java实体类
  10. CSS盒子模型(框模型)