查看更多:
mybatis——select、insert、update、delete
$与#的区别
1 #是将传入的值当做字符串的形式,eg:select id,name,age from student where id =#{id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id ='1'.
2 $是将传入的数据直接显示生成sql语句,eg:select id,name,age from student where id =${id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id = 1.
3 使用#可以很大程度上防止sql注入。(语句的拼接)
4 但是如果使用在order by 中就需要使用 $.
本文详细解析了MyBatis中$与#符号的区别及应用场景,重点介绍了它们如何影响SQL语句的生成与执行,强调了#对于防止SQL注入的重要作用。
224

被折叠的 条评论
为什么被折叠?



