zoukankan      html  css  js  c++  java
  • MyBatis传参数是map的foreach实现方式

    声明一个value为map的map,然后在foreach的时候

    collection="key"

    controller层:

    String district="章贡区";

    String [] ids={"1","2","3"};

    map.put("district",district);

    map.put("idArr",ids);

    xml:注意ids一定要和map中的key一致

    <select id="queryByDistrictList" resultType="io.renren.modules.mall.entity.SpuGoodsEntity">
            select * from spu_goods spu,shop s 
            where spu.shop_id=s.id and s.town=#{district} and spu.ext1='no' and spu.goods_state=0 and spu.category_id in
            <foreach item="idArr" collection="idArr" open="(" separator="," close=")">
                #{idArr}
            </foreach>        
             <if test="offset != null and limit != null">
                limit #{offset}, #{limit}
            </if> 
        </select>
  • 相关阅读:
    读书笔记第四章
    读书笔记第三章
    读书笔记第二章
    读书笔记第一章
    第十章 读书笔记
    第九章 读书笔记
    第八章读书笔记
    第七章读书笔记
    第六章读书笔记
    第五章读书笔记
  • 原文地址:https://www.cnblogs.com/SmallStrange/p/12982379.html
Copyright © 2011-2022 走看看