代码如下:
List<Item> getItemByNames(@Param("collection") Set<String> names, @Param("type") Integer type);
注意使用了Param注解
在mapper文件中
<select id="getItemByNames" resultMap="BaseResultMap">
select id,name from item
where name in
<foreach collection="collection" open="(" close = ")" item = "item" index = "index" separator=",">
#{item}
</foreach>
and type = #{type}
</select>
可以直接通过param属性直接获取到相应的值。