When using orderby dynamic parameters when sorting MyBatis, you need to pay attention, use $ instead of #

Source: http://www.makaidong.com/%E6%95%B0%E6%8D%AE%E5%BA%93/204703.shtml
Comment:
When using order by dynamic parameters in mybatis sorting, you need to pay attention, use $ Instead of #
by default, using a syntax of the form #{} will cause mybatis to create a prepared statement attribute and set a safe value (like ? ) in the context of it. This is safe, fast and preferred, sometimes you just want to insert an unchanged string directly into the sql statement. For example, like order by, you can use it like this:
order by ${columnname}
where mybatis does not modify or escape strings.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327034013&siteId=291194637