MySQL in 和 like 使用#{} 进行参数引入出错

1.使用 in #{list} 是报错的 

所以 使用

<if test="entity.deptIds!=null and entity.deptIds.size >0 ">
and dept_id in
<foreach collection="entity.deptIds" item="deptId" close=")" open="(" separator=",">
#{deptId}
</foreach>
</if>

不能使用$ 防止sql注入

2.like #{} 也是不行的

所以采用字符串拼接的方式进行 变量的引入

meter_type_message like concat('%',#{entity.meterTypeMessage},'%')

原文地址:https://www.cnblogs.com/xiatc/p/13273004.html