1, 多个参数传递用 map 或实体封装后再传给 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
来源: http://www.bubuko.com/infodetail-2733425.html