输入参数:parameterType
1.类型为 简单类型(8个基本类型+String)
&&#{}、${}的区别
1.不同点:
a.格式不同
#{任意值}
${value} ,其中的标识符只能是value
b.输出字符串不同
#{}自动给String类型加上‘ ’ (自动类型转换)
${} 原样输出,但是适合于动态排序(动态字段)
select stuno,stuname,stuage from student where stuname = #{value}
select stuno,stuname,stuage from student where stuname = '${value}'
动态排序:
select stuno,stuname,stuage from student order by ${value} asc
c.#{}可以防止SQL注入
${}不可以防止SQL注入
2.相同点:
a.都可以 获取对象的值 (嵌套类型对象)
i.获取对象值:
模糊查询,方式一:
select stuno,stuname,stuage from student where stuage= #{stuAge} or stuname like #{stuName}
Student student = new Student();
student.setStuAge(24);
student.setStuName("%w%");
List<Student> students = studentMapper.queryStudentBystuageOrstuName(student) ;//接口的方法->SQL
模糊查询,方式二:
student.setStuName("w");
select stuno,stuname,stuage from student where stuage= #{stuAge} or stuname like '%${stuName}%'
ii.嵌套类型对象
1万+

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



