zoukankan      html  css  js  c++  java
  • mybatis动态sql id in sids

    在使用mybatis动态sql查询时,如果传递的参数为List,比如List<Long>,或者一个对象,对象的一个属性为List.使用如下方式

    1.aaaMapper.java

    中参数的写法:这里可以不加@param,但是最好加上

      1 @Param("isAsc")Boolean isAsc,String gxlx, List<String> flsids 

    2.aaaMapper.xml

    这里我想用sid in sids ,需要这样写

    1 <if test="flsids != null and flsids.size>0 ">
    2 and wj.flsid in
    3     <foreach item="item" index="index" collection="flsids" open="(" separator=","     close=")">
    4     #{item}
    5     </foreach>
    6 </if>

    3.controller.java

    这里传参必须加上@RequestParam(value = "sids"),否则会报错:No primary or default constructor found for interface java.util.List

     1 @RequestParam(value = "sids") List<Long>sids, 

    如果sids不是必须的,应该加上required = false,否则会报错:Required List parameter 'sids' is not present 

     1 @RequestParam(value = "sids",required = false)List<Long>sids 

  • 相关阅读:
    【题解】【HAOI2011】Problem b
    【题解】完全平方数
    sqoop安装
    hive安装
    hbase分布式安装
    zookeeper分布式安装
    hadoop分布式安装
    zabbix proxy安装及使用
    web数据存储
    js格式
  • 原文地址:https://www.cnblogs.com/fxx5/p/14327382.html
Copyright © 2011-2022 走看看