Java 在使用@Select遇到的问题:拼接字符串将数组拼为了字符串


Java再用@Select拼接sql语句时候,

#{参数名}:是加引号的

${参数名}:是不加引号的

 

例如:

userIds为List或者数组,值为1,2,3,4,5

1.@Select("select * from users where userId in  (#{userIds})")

翻译为sql语句之后为:select * from users where userId in ('1,2,3,4,5')

2.@Select("select * from users where userId in  (${userIds})")

翻译为sql语句之后为:select * from users where userId in (1,2,3,4,5)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM