区别:
#{},用于传递参数,相当于一个占位符,可以防止sql注入,安全;
${},用于sql的拼接,常用语group by,order by等不能使用占位符的语句中;
用法:
#{}
<if test="condition.userId != null and condition.userId != ''"> AND user_id = #{condition.userId ,jdbcType=VARCHAR} </if>${}
<select id="get" parameterType="java.util.Map" resultMap="test"> SELECT <include refid="sql_column_list" /> FROM test <trim PRefix="WHERE" prefixOverrides="AND"> <include refid="sql_condition" /> </trim> <if test="orderBy != null"> ORDER BY ${orderBy} </if> LIMIT 1 </select>新闻热点
疑难解答