<select id="queryList" resultType="com.performancetest.modules.ptest.entity.StressTestSlaveEntity" > select * from test_stress_slave <where> <if test="slaveName != null and slaveName.trim() != ''"> slave_name like concat('%', #{slaveName}, '%') </if> <if test="status != null"> `status` = #{status} </if> <if test="slaveIds != null and slaveIds.isEmpty()==false"> slave_id in
-- collection為要迭代的變量,item為單個元素
<foreach item="slaveId" collection="slaveIds" open="(" separator="," close=")"> #{slaveId} </foreach> </if> </select>