代码如下
<select id="test" returnType="java.lang.Integer">
select count(*) from test t where #{col} = 'xxxx'
</select>
Integer test(@Param("col") String col);
当时使用的时候返回的结果非常奇怪,不描述了。
正确写法 #{col} 改为 ${col},
<select id="test" returnType="java.lang.Integer">
select count(*) from test t where ${col} = 'xxxx'
</select>
本文描述了一段使用MyBatis框架进行数据库操作的代码,在使用动态SQL时,因参数解析方式错误导致的问题及解决方法。原本使用#{col}
3430

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



