今天碰到個問題,解決了好久才搞定,來記錄下,但願能夠幫助到你們java
貼錯誤源碼:sql
這是一個根據list集合的查找數據的 sql,在接收list的時候加了判斷 list != ‘ ’ 「」,引發了集合與Stirng類型的比較,故報錯blog
<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>