mybtis的数据库XML文件对参数的书写格式有两种
① SELECT * FROM tableName
where time>=#{startTime} and time <=#{endTime} order by time
②SELECT * FROM tableName
where time>= '${param1}'and time <= '${param1}' order by time
当你使用了使用@Param注解来声明参数时,如果使用 #{} 或 ${} 的方式都可以。
① SELECT * FROM tableName
where time>=#{startTime} and time <=#{endTime} order by time
② SELECT * FROM tableName
where time>=${startTime} and time <=${endTime} order by time
当你不使用@Param注解来声明参数时,必须使用使用 #{}方式。如果使用 ${} 的方式,会报错。
SELECT * FROM tableName
where time>=${startTime} and time <=${endTime} order by time