码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis学习$与#号取值区别

时间:2018-08-19 00:58:04      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:tis   比较   封装   参数传递   pass   参数   mybatis   can   sel   

1,多个参数传递用map或实体封装后再传给myBatis,

 

 

mybatis学习$与#号取值区别

#{} 1.加了单引号,  2.#号写是可以防止sql注入,比较安全

select * from user where username=#{username} and password=#{password}  变成 ...where username=‘张三’ and password=‘123’

${}  2.没有加单引号  2.${}写法无法防止sql注入(模湖查询时用‘%${username}%’) 或用cancat (‘%‘,${username},‘%‘)

select * from user where username=${username} and password=${password}  变成 ...where username=张三 and password=123

 

mybatis学习$与#号取值区别

标签:tis   比较   封装   参数传递   pass   参数   mybatis   can   sel   

原文地址:https://www.cnblogs.com/gzhbk/p/9499160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!