为了防止SQL注入,mybatis使用模糊查询时也要避免使用$$来进行传值.下面是两个不同数据库的mybatis的模糊查询传值
mysql:
select * from stu where name like concat('%',#name #,'%')
oracle:
select * from stu where name like '%'||#name #||'%'
本文深入探讨了如何在MyBatis中使用模糊查询时防止SQL注入,通过实例展示了MySQL和Oracle数据库环境下安全的查询语句编写方式。
为了防止SQL注入,mybatis使用模糊查询时也要避免使用$$来进行传值.下面是两个不同数据库的mybatis的模糊查询传值
mysql:
select * from stu where name like concat('%',#name #,'%')
oracle:
select * from stu where name like '%'||#name #||'%'
1076
986

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