只有一个参数,且参数的类型是 List, <foreach> 标签中的 collection 属性要必须指定为 list 。
1 2 3 4 5 6 7
<selectid="findByIdsMap"resultMap="BaseResultMap"> select <includerefid="Base_Column_List" /> from user where id in <foreachitem="item"index="index"collection="list"open="("separator=","close=")"> #{item} </foreach> </select>
<selectid="findByIdsMap"resultMap="BaseResultMap"> select <includerefid="Base_Column_List" /> from user where id in <foreachitem="item"index="index"collection="array"open="("separator=","close=")"> #{item} </foreach> </select>
<selectid="findByIdsMap"resultMap="BaseResultMap"> select * from user where id in <foreachitem="item"index="index"collection="ids"open="("separator=","close=")"> #{item} </foreach> </select>
<selectid="findbyIds"resultMap="BaseResultMap"> select * from user where id in <foreachitem="item"index="index"collection="array"open="("separator=","close=")"> #{item} </foreach> </select>
<updateid="updateBatchStatus"parameterType="applyApiDetailVO"> update apply_api_detail set status = #{status} where id in <foreachcollection="detailList"item="item"index="index"open="("close=")"separator=","> #{detailList[${index}].id, jdbcType=BIGINT} </foreach> </update>
Controller 使用 ApplyApiDetailVO 对象接收参数,页面传参如下:
Contrller 层接口:
1 2 3 4
@PostMapping("/updateStatusByApp") public ResponseModel updateStatusByApp(@RequestBody ApplyApiDetailVO applyApiDetailVO){ //........... }