mybatis 遍历map;

允我心安 提交于 2021-01-03 17:23:01

mybatis 遍历map;

参考http://blog.csdn.net/hj7jay/article/details/78652050

ps:

${m[key]}
这是显示 打印的key读value写法
注意:根据key获取到map的方式,如下:
#{content[${key}]} 或者 ${content[key]}方式,两个方式的#和$不能随便换位置。
如:
<!--查同步表-->
    <insert id="insertSynData" parameterType="java.util.Map" >
        insert into ${tb_target}(${columns})
        <foreach collection="list" item="m" open="" close="" separator=" union all ">
            select
            <foreach collection="m.keys" item="key" open="" close="" separator=",">
                <choose>
                    <when test="key=='案例主题'">
                        #{m[${key}],jdbcType=CLOB}
                    </when>
                    <otherwise>
                        ${m[key]}
                    </otherwise>
                </choose>
            </foreach>
            from dual
        </foreach>
    </insert>

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!