写了一条sql,在db2数据库中可以执行,但是转换成mybatis的mapper文件后,在执行排序操作时报该错误。

我排序是这样写的

<if test="orderStr != null">
ORDER BY #{orderStr}
</if>

看了一下其他地方的写法发现使用$,而不是#,改成如下就可以了

<if test="orderStr != null">
ORDER BY ${orderStr}
</if>

 

相关文章: