Mybatis中${}和#{}的区别?

$  取完值以后直接拼接到sql语句后面去,相当于字符串的拼接,造成sql注入攻击,安全性问题

#  相当于preparedStatement, ????  不会造成sql注入攻击,比较安全

 

List<PersonBean>  getByCondition3(@Param("name") String name, @Param("add") String add);

 <select id="getByCondition" resultMap="stu">

        select *from student where sname=${name}

 </select>

 

sql结果:

select *from student where sname=1 or 1=1

select *from student where sname='1 or 1=1'

原文地址:https://www.cnblogs.com/masterhxh/p/12896626.html