Cause: java.lang.IllegalArgumentException: invalid comparison: java.util.ArrayList and java.lang.String

 翻译过来就是

原因:java.lang.IllegalArgumentException:无效比较:java.util.ArrayList和java.lang.String

 

这个情况在list集合查找数据的sql中出的问题,在接受list的时候加了判断  list!='' ,引起了集合与String类型的比较

<choose>
      <when test="names!= null and names.size!=''">
        and name in
        <foreach collection="names" item="name" index="index" open="(" close=")" separator=",">
          #{name}
        </foreach>
      </when>
      <otherwise>
        and name= ''
      </otherwise>
    </choose>

换成

<choose>
      <when test="names!= null and names.size>0">
        and name in
        <foreach collection="names" item="name" index="index" open="(" close=")" separator=",">
          #{name}
        </foreach>
      </when>
      <otherwise>
        and name= ''
      </otherwise>
    </choose>

 

posted @ 2020-12-09 00:34  King-DA  阅读(1694)  评论(0编辑  收藏  举报