iBatis解决sql注入
2011-04-10 18:18
246 查看
iBatis解决sql注入
(1) ibatis xml配置:下面的写法只是简单的转义 name like '%$name$%'
(2) 这时会导致sql注入问题,比如参数name传进一个单引号“'”,生成的sql语句会是:name like '%'%'
(3) 解决方法是利用字符串连接的方式来构成sql语句 name like '%'||'#name#'||'%'
(4) 这样参数都会经过预编译,就不会发生sql注入问题了。
(5) #与$区别:
#xxx# 代表xxx是属性值,map里面的key或者是你的pojo对象里面的属性, ibatis会自动在它的外面加上引号,表现在sql语句是这样的 where xxx = 'xxx' ;
$xxx$ 则是把xxx作为字符串拼接到你的sql语句中, 比如 order by topicId , 语句这样写 ... order by #xxx# ibatis 就会把他翻译成 order by 'topicId' (这样就会报错) 语句这样写 ... order by $xxx$ ibatis 就会把他翻译成 order by topicId
if ($ != jQuery) {
$ = jQuery.noConflict();
}
var isLogined = true;
var cb_blogId = 62750;
var cb_entryId = 1865749;
var cb_blogApp = "chenfery";
var cb_blogUserGuid = "8f18efef-5aa7-de11-ba8f-001cf0cd104b";
var cb_entryCreatedDate = '2010/10/31 21:38:00';
(1) ibatis xml配置:下面的写法只是简单的转义 name like '%$name$%'
(2) 这时会导致sql注入问题,比如参数name传进一个单引号“'”,生成的sql语句会是:name like '%'%'
(3) 解决方法是利用字符串连接的方式来构成sql语句 name like '%'||'#name#'||'%'
(4) 这样参数都会经过预编译,就不会发生sql注入问题了。
(5) #与$区别:
#xxx# 代表xxx是属性值,map里面的key或者是你的pojo对象里面的属性, ibatis会自动在它的外面加上引号,表现在sql语句是这样的 where xxx = 'xxx' ;
$xxx$ 则是把xxx作为字符串拼接到你的sql语句中, 比如 order by topicId , 语句这样写 ... order by #xxx# ibatis 就会把他翻译成 order by 'topicId' (这样就会报错) 语句这样写 ... order by $xxx$ ibatis 就会把他翻译成 order by topicId
if ($ != jQuery) {
$ = jQuery.noConflict();
}
var isLogined = true;
var cb_blogId = 62750;
var cb_entryId = 1865749;
var cb_blogApp = "chenfery";
var cb_blogUserGuid = "8f18efef-5aa7-de11-ba8f-001cf0cd104b";
var cb_entryCreatedDate = '2010/10/31 21:38:00';
相关文章推荐
- 通过ibatis解决sql注入问题
- iBatis解决sql注入问题的方法
- ibatis解决sql注入问题
- ibatis解决sql注入问题 .
- iBatis解决sql注入
- ibatis解决sql注入问题
- ibatis解决sql注入问题
- iBatis解决sql注入
- iBatis解决自动防止sql注入
- ibatis解决sql注入问题
- iBatis解决sql注入
- ibatis解决sql注入问题
- ibatis解决sql注入问题 .
- (转载)ibatis:解决sql注入问题
- IBatis.Net使用总结(一)-- IBatis解决SQL注入(#与$的区别)
- ibatis解决sql注入问题
- iBatis的SQL注入问题
- org.apache.ibatis.binding.BindingException 奇葩问题解决
- 解决mapper绑定异常:nested exception is org.apache.ibatis.binding.BindingException
- ibatis处理器异常(executor.ExecutorException)解决方法