mybatis使用order by注意

直接用动态参数生成,不会排序:

<if test="orderColumn!=null and orderColumn != ''">
ORDER BY #{orderColumn} #{orderDir}
</if>

需要将#改为$:

<if test="orderColumn!=null and orderColumn != ''">
ORDER BY ${orderColumn} ${orderDir}
</if>

posted @ 2015-05-07 11:45  星空中的启明星  阅读(7421)  评论(0编辑  收藏  举报