mybatis in parameter dynamic splicing

// 接口
public List<User> findByIdList(List<Integer> idList);

<select id="findByIdList" resultType="com.lxw.pojo.User">
	SELECT *
	FROM user
	<where>
        <if test="list!= null and list.size() > 0">
            id IN
            <foreach collection="list" item="ietm" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
	</where>
</select>

 

Guess you like

Origin blog.csdn.net/lw112190/article/details/107244821