zoukankan      html  css  js  c++  java
  • mybatis 传map参数

    第一步在你的mapper写上:

        List<WeixinUserLocationList> findweixinUserLocations(@Param("params") Map<String, Object> map);

    注意就是注解@param 这个,是mybatis的

    然后在xml中这样写:

    <if test="params.accountId!=null">
                and a.accountid=#{params.accountId}
            </if>
            <if test="params.nickname!=null and params.nickname !=''">
                and a.nickname like '%${params.nickname}%'
            </if>
            <if test="params.beginDate!=null and params.beginDate!=''">
                and date_format(a.createtime,'%Y-%m-%d')>=${params.beginDate}
            </if>
            <if test="params.endDate!=null and params.endDate!=''">
            <![CDATA[    and date_format(a.createtime,'%Y-%m-%d')<=${params.endDate}  ]]>     
            </if>
    ${params.nickname}这种写法参数默认是传字符串,
    #{params.accountId}可以取Long,Integer之类的。

    好久没有用了,今天记一下...
  • 相关阅读:
    hdu 1754 线段树 注意线段树节点的设计 求什么,设什么
    hdu 4015 概率题
    poj 1950 回溯
    最大上升子序列
    JVM学习博客
    2012
    i am alone at a crossroads
    易知难
    牢骚。。
    something
  • 原文地址:https://www.cnblogs.com/huzi007/p/5969711.html
Copyright © 2011-2022 走看看