1、要注意传的参数类型
/** item\index为固定写法,collection如果是一个参数且类型是arry 那么就是arry 如果一个参数且类型是List,那么就是List
open:遍历之前添加的内容,separater:遍历的每个内容之间的分隔符,colse:遍历之后添加的内容**/
下面是例子:
<select id="interfaceFunction" resultType="String" paramterType="java.lang.HashMap">
�select distinct customNo
from table
where name=#{name}
and id in
<foreach item="item" index="index" collection="ids" open="(" separater="," close=")">
#{item}
</foreach>
</select>
2、传参数的时候:
2.1因为指定是HashMap,所以我们通常这样传,可以避免出现一个和多个参数不同的影响:
Map<String,Object> map=new HashMap<String,Object>();
map.put("name","zhangsan");
List<String> ids=new ArrayList<String>();
ids.add("值1") ;ids.add("值2") ;ids.add("值3") ;
map.put("id",ids);
//map.put("id",Arrays.asList(“值1”,“值2”,“值3”)); ArrayList的初始化
List<String> list=xxxxxMapper.interfaceFunction(map);//调用









网友评论