@Select("<script> select name from subject where id in <foreach item='item' index='index' collection='subjectIds' open='(' separator=',' close=')'> #{item} </foreach> </script>") ArrayList<String> getSubject(@Param("subjectIds") ArrayList<Integer> subjectIds);
说明:上述方式其实是一种注解完全代替xml的方法。
其中的foreach的collection直接写成@param中的值,item的值与#{}中的值一致即可。