MyBatis 模糊查询 防止Sql注入
2018-03-06 15:56
471 查看
#{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全;
${xxx},使用字符串拼接,可以SQL注入;
like查询不小心会有漏洞,正确写法如下:
Mysql:
[sql] view
plain copy
select * from t_user where name like concat('%', #{name}, '%')
Oracle:
[sql] view
plain copy
select * from t_user where name like '%' || #{name} || '%'
SQLServer:
[sql] view
plain copy
select * from t_user where name like '%' + #{name} + '%'
转载地址:http://blog.csdn.net/pange1991/article/details/47810187
${xxx},使用字符串拼接,可以SQL注入;
like查询不小心会有漏洞,正确写法如下:
Mysql:
[sql] view
plain copy
select * from t_user where name like concat('%', #{name}, '%')
Oracle:
[sql] view
plain copy
select * from t_user where name like '%' || #{name} || '%'
SQLServer:
[sql] view
plain copy
select * from t_user where name like '%' + #{name} + '%'
转载地址:http://blog.csdn.net/pange1991/article/details/47810187
相关文章推荐
- mybatis like %% 模糊查询防sql 注入
- MyBatis模糊查询的sql拼接
- mybatis中怎么使用like形成动态模糊查询,错误使用CONCAT拼接sql的看过来
- MyBatis入门07--实现sql动态模糊查询
- Mybatis学习总结之动态SQL与模糊查询
- MyBatis SQLServer 模糊查询LIKE、本年、本月、近三月、近两月
- mybatis模糊查询如何防止sql注入
- mybatis中模糊查询的sql语句
- 使用mybatis查询sql注入到 map 中,唯空字段 也获取出来
- mybatis中模糊查询sql语句
- Mybatis模糊查询SQL语句
- Mybatis学习总结之动态SQL与模糊查询
- SQL学习笔记[1] - 防注入攻击:一个参数传值+模糊查询的参考写法
- java mybatis 中sql 模糊查询
- 【Mybatis】Mybatis的sql模糊查询
- 【转】mybatis如何防止sql注入
- 03. mybatis 动态sql && 模糊查询
- mybatis 动态SQL与模糊查询
- 【Mybatis学习总结六】动态SQL与模糊查询
- mybatis 3如何防止SQL注入