在IbatiS的select中有两个占位符 # 和 $
我们先看一个查询语句:
select * from user where Name = #userName#;
ibatis解析成:select * from user where Name = ? 这样的语句,然后在填充参数。
select * from user where Name = ‘$userName$’
ibatis解析成:select * from user where Name = '传过来的值' (传过来的值直接填充)
本文详细解释了IbatiS框架中#和$两种参数占位符的不同用法。#作为预编译参数占位符,提高了SQL执行效率并能防止SQL注入攻击;而$直接替换为字符串,可能引入SQL注入风险。

557

被折叠的 条评论
为什么被折叠?



