1. 程式人生 > >mybatis中陣列空值查詢條件

mybatis中陣列空值查詢條件

原:<if test="payOrdVo.bkRtRmkArr != null and payOrdVo.bkRtRmkArr != ' ' ">

and 
<foreach item="item" index="index" collection="payOrdVo.bkRtRmkArr"
open="(" separator=" or " close=")">
 p. BK_RT_RMK like '%'||#{item}||'%'
 </foreach>
</if> 

傳過來的可能是一個數組payOrdVo.bkRtRmkArr[] ,有值為payOrdVo.bkRtRmkArr[0] =" ",條件仍然符合

現:<if test="payOrdVo.bkRtRmkArr != null and payOrdVo.bkRtRmkArr != '' and payOrdVo.bkRtRmkArr[0] !=' '  " >

and 
<foreach item="item" index="index" collection="payOrdVo.bkRtRmkArr"
open="(" separator=" or " close=")">
p. BK_RT_RMK like '%'||#{item}||'%'
</foreach>
</if>