-----------传入数组------返回list<string>----------
String[] sendPersonIdArr = sendPersonId.split(",");
List<String> list = staffInfoService.ListPhonesByIds(sendPersonIdArr);
<!-- 通过userIds查询员工的电话-->
	<select id="ListPhonesByIds" parameterType="String" resultType="String">
	 	SELECT h.telphone from hr_staff_info h left JOIN sys_user u on h.STAFFINFO_ID=u.STAFF_ID where 
 			u.id in  
 			<foreach collection="array" index="index" item="item" open="(" separator="," close=")">
				 #{item}
			</foreach>
	</select>
-----传入List<string>----返回List<User>------
 
public List<User> findByUserIdList(List<String> userlist) throws Exception {
	return (List<User>) dao.findForList("UserMapper.findByUserIdList", userlist);
}
<!-- 通过userId的list来查询userlist -->
	<select id="findByUserIdList" parameterType="java.util.List" resultMap="userResultMap" >
	select * from sys_user  where id in 
	 <foreach collection="list"  item="item" index="index" open="(" separator="," close=")">  
		 #{item}
	</foreach>
	</select>
sql中我们可以传入一个list或者一个数组,返回一个list。
这里用到了sql中的 In,用到了sql中的遍历。
在我们要向mapper.xml中传递String参数的时候,需要sql中设置
parameterType="String"
同时 要保证impl中的参数名和sql中的名字要一致。
如下:
@Override
	public User findByUE(String userId)throws Exception{
		return (User)dao.findForObject("UserMapper.findById",userId);
	}
	
	sql :
	u.id = #{userId}
sql中出入一个list,返回一个list
原文:http://blog.51cto.com/jianboli/2045357