首页 > 数据库技术 > 详细

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

时间:2020-07-09 13:12:10      阅读:148      评论:0      收藏:0      [点我收藏+]

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

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!