mybatis,mybatis 注解 占位符

 2023-10-05 阅读 34 评论 0

摘要:#{} 自動進行 java 類型和 jdbc 類型轉換,#{}可以有效防止 sql 注入。 select * from user where username = #{username} username = 'wxy' 為字符串時,則轉換為 select * from user where username = 'wxy' 自動加上引號 ${} 直接 傳入的

#{}
自動進行 java 類型和 jdbc 類型轉換,#{}可以有效防止 sql 注入。
select * from user where username = #{username}
username = 'wxy' 為字符串時,則轉換為
select * from user where username = 'wxy'
自動加上引號

${}
直接 傳入的內容拼接在 sql 中且不進行 jdbc 類型轉換,
select * from user where username = ${username}
username = 'wxy' 為字符串時,則轉換為
select * from user where username = wxy
不加引號,直接拼貼

所以#{}可以防止注入,不能修改sql語句本身,只能修改值,而${}則既可修改SQL本身,也可修改值.

neo4j中label,不是字符串,就需要使用${}來注入

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/115748.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息