1.重点易遗漏之处
给在mapper类对应的方法参数加上@Param注解
public List<Song> selectSongListByIds(@Param(value = "songIds") String songIds);
2.在xml中使用${}、#{}皆可,但有细微差别
使用${}在MyBatis中已可直接取到值,与’'结合生成sql格式字符串已是sql语法问题
<select id="selectSongListByIds" parameterType="String" resultMap="SongResult">
<include refid="selectSongVo"/>
<where>
<if test="songIds != null "> regexp_like('${songIds}', concat('(,', song_id, ',)'))</if>
</where>
</select>
使用#{}是取到值的同时直接生成sql格式字符串
<select id="selectSongListByIds" parameterType="String" resultMap="SongResult">
<include refid="selectSongVo"/>
<where>
<if test="songIds != null "> regexp_like(#{songIds}, concat('(,', song_id, ',)'))</if>
</where>
</select>