mybatis $ 和 # 的区别
第一种写法:
<select id="selectByScIds" resultMap="BaseResultMap" parameterType="com.management.ScRequest">
select
<include refid="Base_Column_List" />
from sc_template
<where>
<if test="plcVersion!=null">
plc_version=#{plcVersion,jdbcType=VARCHAR}
</if>
<if test="scIds!=null">
and sc_id in (${scIds})
</if>
</where>
</select>
第二种写法:
<select id="selectByScIds" resultMap="BaseResultMap" parameterType="com.management.ScRequest">
select
<include refid="Base_Column_List" />
from sc_template
<where>
<if test="plcVersion!=null">
plc_version=#{plcVersion,jdbcType=VARCHAR}
</if>
<if test="scIds!=null">
and sc_id in (#{scIds})
</if>
</where>
</select>
注意看 and sc_id in (${scIds}) 和 and sc_id in (#{scIds}) ;
$ 和 # 的区别 # : (“105011,105012,105013,105004,429063,213020,429062”)

浙公网安备 33010602011771号