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},'%')


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM