第一种:使用${...}
![](https://i-blog.csdnimg.cn/blog_migrate/c3f00f6054ec80fe56e959978914bb6d.png)
注意:由于$是参数直接注入的,导致这种写法,大括号里面不能注明jdbcType,不然会报错。
![](https://i-blog.csdnimg.cn/blog_migrate/a6009e2e58e02c8e10550252519ce236.png)
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'VARCHAR' in 'class com.utry.ucsc.dao.bean.KnowledgeLibraryBean'
弊端:可能会引起sql的注入,平时尽量避免使用${...}
第二种:使用#{...}
![](https://i-blog.csdnimg.cn/blog_migrate/0d757670b938056e9c5648e750e049bf.png)
注意:因为#{...}解析成sql语句时候,会在变量外侧自动加单引号' ',所以这里 % 需要使用双引号" ",不能使用单引号 ' ',不然会查不到任何结果。
第三种:使用CONCAT()函数连接参数形式
![](https://i-blog.csdnimg.cn/blog_migrate/f6e2db01e30e7a6be9cb8e953e756b32.png)