`
hongye612430
  • 浏览: 59538 次
  • 性别: Icon_minigender_1
  • 来自: 安康
社区版块
存档分类
最新评论

ibatis防止SQL注入的办法

阅读更多
常见容易犯错的写法:

select * from page_frame where title like '%$title$%'


这样会引起SQL注入漏洞.

解决方法:

select * from page_frame where title like '%'||#title#||'%'

注意:以上写法在oracle使用。

在mysql中,用这个: select * from page_frame where title CONCAT('%',#title#,'%')
在mssql中,用这个: select * from page_frame where '%'+#name #+'%  
还有一种办法是将参数里的# $ ' 等字符串转义替换掉
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics