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 like CONCAT('%',#title#,'%') 
在mssql中,用这个: select * from page_frame where '%'+#name #+'%  

posted on 2016-02-18 10:51  书山压力大  阅读(853)  评论(0)    收藏  举报