mybatis XML中 遍历map写法

匿名 (未验证) 提交于 2019-12-02 20:41:15
   <select id="selectMapTest" parameterType="java.util.HashMap" resultMap="BaseResultMap">         <foreach collection="map1" index="key" item="ent" separator="union">             SELECT *             FROM User             where username=#{key}             and userpass in             <foreach collection="ent" item="id" separator="," open="(" close=")">                 #{id}             </foreach>         </foreach>      </select>

 对应的mapper中是:

//map测试List<User>  selectMapTest(@Param("map1") Map<String,List<Integer>> ma1);注意:foreach标签中的index就是map的key值
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!