标签:
比如:根据班级号查询学生的信息,参数是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());
}
标签:
原文地址:http://www.cnblogs.com/fdx-web/p/4766481.html