在mybatis中,配置文件中sql的值,用#{}表示,例如:
<select id="getTeacher" resultType="Teacher">
SELECT t_id id, t_name name FROM teacher WHERE t_id=#{id}
</select>
#{id}最终发送的sql为:select t_id id,t_name name from teacher where t_id=1
如果传入的是字符串则会加上'';
如果想直接取传过来的值,不加任何变化的话,用${}取
SELECT t_id id, t_name name FROM teacher WHERE t_id=#{id} order by ${id} ${order} #{}会使用?进行替代,${}会完全将字符串完成替代