- 映射文件对应的接口中,map 参数添加 @Param(“map”) 注解;
void addZdConfig(@Param("map") Map<String, String> rowMap, @Param("zdName") String zd
- 映射文件中使用 map :
<insert id="addZdConfig" parameterType="java.util.Map"> insert into ${zdName} <foreach collection="map.entrySet()" index="key" item="value" open="(" close=")" separator=","> <if test="key != 'zdName'"> ${key} </if> </foreach> values <foreach collection="map.entrySet()" index="key" item="value" open="(" close=")" separator=","> <if test="key != 'zdName'"> #{value} </if> </foreach> </insert>