MyBatis有两种取值符号
输入参数为parameterType
1、当类型为简单类型(8个基本类型+String)时
#{}和${}的区别
a、#{任意值},任意值是指任意的合法标识符即可获得用户传入的参数,但一般为了见名知意都使用对应的变量名。
${
value},其中标识符必须为value
b、#{}:如果输出参数的类型为String,则自动为变量加上单引号(自动类型转换)。
${}:原样输出,但是适用于动态排序(动态字段)如:
select stuno,stuname,stuage from student where stuname = #{
value}
等价于
select stuno,stuname,stuage from student where stuname = '${value}'