【视频 & 交流平台】
http://study.163.com/course/introduction.htm?courseId=1004329008&utm_campaign=commission&utm_source=400000000155061&utm_medium=share
http://study.163.com/course/introduction.htm?courseId=1004638001&utm_campaign=commission&utm_source=400000000155061&utm_medium=share
https://gitee.com/happyangellxq520/spring-boot
http://412887952-qq-com.iteye.com/blog/2321532
【本篇博客,有配套视频,视频地址:《Spring Boot MyBatis升级篇-注解- #和$符号特别篇(高清)》,公众号中点击下面的阅读原文,视频中讲解的更详细】
#、$符号在MyBatis的SQL参数注入有很重要的作用,这两个符号还是需要理解清楚的,不然可能就会写出被攻击的SQL语句了。好了,这篇文章就是为了解决#、$各自的使用场景。
本节大纲:
接下来请移步到微信公众号SpringBoot进行浏览:
具体查看springboot公众号文章(公众号二维码,输入140就会返回文章):
-----------------------------------------------------------
实例说明:
à使用#{}的语句:
@Select("Select * from Demo where name = #{name}") public List<Demo> selectByName1(@Param("name") String name);
说明:这个例子创建一个预编译的语句,看起来像:select * from Demo where name = ?;
观察控制台的SQL打印:
selectByName1 : ==> Preparing: Select * from Demo where name = ? DemoMapper.selectByName1 : ==> Parameters: 王五(String) DemoMapper.selectByName1 : <== Total: 9
视频&交流平台:
http://study.163.com/course/introduction.htm?courseId=1004329008
http://412887952-qq-com.iteye.com/blog/2321532