使用<if> 标签,里面套着 order by 字段不能用 #{xxx} 要用${XXX}
// 错误示范!!!
<if test="orderColumn!=null and orderColumn != ''">
ORDER BY #{orderColumn} #{orderDir}
</if>
// 正确规则!!!
<if test="orderColumn!=null and orderColumn != ''">
ORDER BY ${orderColumn} ${orderDir}
</if>