<if test="status != null and status.size()>0" >
and s.orderstatus in
<foreach collection="status" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
建议对特殊字符进行处理
<if test="status != null and status.size() > 0" >
and s.orderstatus in
<foreach collection="status" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
<if test="null != staffCodeList and staffCodeList.size > 0">and gui.USER_CODE not in<foreach collection="staffCodeList" item="staffCode" open="(" separator="," close=")&quo
今天做项目突然在mybatis的配置文件中使用到了list作为参数,发现判断list的长度时报了错,才发现应该使用size()方法。记录一下希望你们能解决遇到的问题。
在mybtis 的xml文件中判断集合大小有两种写法,说是两种其实也可以说是一种.
1.list.siez() 方法
<if test="term.list!=null and term.list.size()>0 ">
value in <foreach item="id" index="index" collection="term.list" open="(" separator="," close=")"> #{id} </f
在mapper.xml中用if test 判断此集合是否为空的写法如下:
<if test="costsIds != null and costsIds.size()!=0 ">
and standard_costs_id in
<foreach item="item" collection="costsIds" separator="," open="(" close=")">
<if test="list!= null and list.size()>0" >
and s.orderstatus in
<foreach collection="list" item="item" open="(" close=")" separator="," >
#{item}
</foreach>