第一种:list里的元素不是string字符串,而是一个实体类
<if test="studentList!=null and studentList.size>0">
and a.id in
<foreach collection="studentList" index="index" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</if>
第二种:list里的元素是string字符串
<if test="studentIds!=null and studentIds.size>0">
case when a.id in
<foreach collection="studentIds" index="index" item="item" open="(" separator="," close=")">
'${item}'
</foreach>
then 1 else 2 end ,
</if>
总结: # 是起的占位符的作用,但是写在了字符串里面无法起到占位符的作用,这是我们要用 $