Mybatis的.xml文件中传参使用的#{}与${}的区别
在mybatis中#和$的主要区别是:
#传入的参数在SQL中显示为字符串,能够很大程度防止sql注入;
$传入的参数在SqL中直接显示为传入的值,无法防止Sql注入。
例如:
使用#{}:
select * from student where id = #{id}
当我们传递的参数id为 “1” 时,上述 sql 的解析为:
select * from student where id = ...
原创
2019-07-16 14:47:20 ·
1435 阅读 ·
0 评论