欢迎投稿

今日深度:

Mabatis中模糊查询防止sql注入的方法教程,mabati

Mabatis中模糊查询防止sql注入的方法教程,mabatis模糊查询


Mabatis中模糊查询防止sql注入

#{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全;

${xxx},使用字符串拼接,可以SQL注入;

like查询不小心会有漏洞,正确写法如下:

Mysql:

select * from user where name like concat('%', #{name}, '%')   

Oracle:

select * from user where name like '%' || #{name} || '%' 

SQLServer:

select * from user where name like '%' + #{name} + '%'  

www.htsjk.Com true http://www.htsjk.com/Sql_Server/24587.html NewsArticle Mabatis中模糊查询防止sql注入的方法教程,mabatis模糊查询 Mabatis中模糊查询防止sql注入 #{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全; ${xxx},使用字符串拼接,可以SQL注...
评论暂时关闭