java.lang.NullPointerException: target is null for method size
产生原因:空指针异常,顾名思义,代码里有null.什么什么导致的。
这个错误是由于项目中使用mybatis写sql语法导致的:
下面为错误示范:
<if test="compIdList == null and compIdList.size() > 0">AND tt.comp_id in<foreach collection="compIdList" item="compId" open="(" separator="," close=")">#{compId}</foreach> </if>
下面为改正后示范: <if test="compIdList != null and compIdList.size() > 0">AND tt.comp_id in<foreach collection="compIdList" item="compId" open="(" separator="," close=")">#{compId}</foreach> </if>
两者区别:compIdList == null 改成了 compIdList != null 就好了。