Mybatis模糊查询

Mybatis模糊查询,第1张

一、#{}和${}的区别是什么?

${}是字符串替换

#{}是预处理:使用#{}可以有效的防止SQL注入,提高系统安全性。

Mybatis在处理${}时,就是把${}直接替换成变量的值。

而Mybatis在处理#{}时,会对sql语句进行预处理,将sql中的#{}替换为?号,调用PreparedStatement的set方法来赋值;


PreparedStatement:可以防止sql注入(预处理对非法输入的 ' 进行\转义)。

Statement:不能防止sql注入。

二、Mybatis模糊查询
 select * from auth_user where phone like #{phone}
select * from  auth_user where phone like  '%' #{phone} '%'
三、跨页面传值

在页面button按钮绑定 @click事件 modifyUser(user.id)带上user对象的id






上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存