今天碰到個問題,解決了很久才搞定,來記錄下,希望可以幫助到大家
貼錯誤源碼:
這是一個根據list集合的查找數據的 sql,在接收list的時候加了判斷 list != ‘ ’ “”,引起了集合與Stirng類型的比較,故報錯
<if test="list != null and list != ''"> and ul.loan_id in <foreach collection="list" index="index" item="loanIdList" open="(" separator="," close=")"> #{loanIdList} </foreach> </if>
解決方案: 將判斷條件改為 : list.size >0
<if test="list != null and list.size > 0"> and ul.loan_id in <foreach collection="list" index="index" item="loanIdList" open="(" separator="," close=")"> #{loanIdList} </foreach> </if>