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