码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • xml中in的使用


    目录

    一、简介

     二、使用

    1、参数为list

    2、参数为Array

    3、参数为Map

    4、参数为对象(集合在对象中)

    XML中大于、小于、不等于符号使用


    一、简介

    在xml中使用in查询需要使用foreach标签

    1. <foreach item="item" collection="list" index="index" open="(" separator="," close=")">
    2. #{item}
    3. foreach>

    foreach的属性:

    item:表示集合中每一个元素进行迭代的别名。

    collection:为参数类型。

    index:指定的名字,表示每次迭代的位置。

    open:表示该语句以什么开始。

    separator:表示在每次进行迭代时以什么符号为分隔符。

    close:表示以什么结束

     二、使用

    1、参数为list

    mapper:

    List  selectName(List ids);

     xml:

    1. <select id="selectName" resultType="String">
    2. select name from sys_app where id in
    3. <foreach item="item" collection="list" index="index" open="(" separator="," close=")">
    4. #{item}
    5. foreach>
    6. select>

    2、参数为Array

    mapper:

    List  selectName(String[] ids);

    xml:

    1. <select id="selectName" resultType="string">
    2. select name from sys_app where id in
    3. <foreach item="item" collection="array" index="index" open="(" separator="," close=")">
    4. #{item}
    5. foreach>
    6. select>

    3、参数为Map

    1. List list = new ArrayList<>();
    2. list.add(1);
    3. list.add(2);
    4. Map map =new HashMap<>();
    5. map.put("ids",list);
    6. map.put("parms","sss");

    mapper:

    List<String> selecyName(Map map);
    

    xml:

    1. <select id="selectName" resultType="String">
    2. select name from sys_app where id in
    3. <foreach item="item" collection="ids" index="index" open="(" separator="," close=")">
    4. #{item}
    5. foreach>
    6. select>

    4、参数为对象(集合在对象中)

    对象:

    1. @Data
    2. @ApiModel(value = "user",description = "用户BO")
    3. public class UserBo extends BaseEntity {
    4. @ApiModelProperty(value = "id")
    5. private Integer id;
    6. @ApiModelProperty(value = "姓名")
    7. private String name;
    8. @ApiModelProperty(value = "年龄")
    9. private Integer age;
    10. @ApiModelProperty(value = "性别")
    11. private String sex;
    12. private List ids;
    13. }

    mapper:

    List getInfoList(@Param("query") UserBo bo);

    xml:

    1. <select id="getInfoList" resultType="com.system.domain.vo.UserVo">
    2. select *
    3. from user
    4. where is_del = 0
    5. <if test="query.ids != null">
    6. and id in
    7. <foreach item="item" collection="query.ids" index="index" open="(" separator="," close=")">
    8. #{item}
    9. foreach>
    10. if>
    11. select>

    XML中大于、小于、不等于符号使用

    符号原符号替换符号
    小于<<
    小于等于<=<=
    大于>>
    大于等于>=>=
    不等于<><>
    与&&
    单引号'&apos
    双引号""

  • 相关阅读:
    Yakit工具篇:专项漏洞检测的配置和使用
    【Datawhale】AI夏令营第三期——基于论文摘要的文本分类笔记(下)
    sklearn机器学习——day07
    two ways to customize unordered_set
    软件测试项目实战,一比一还原可以写进简历的
    ADC采集到的数值和电压值、频率有什么联系?
    AOP是什么?如何使用AOP?
    独立产品灵感周刊 DecoHack #038 - 纽约市 90 年代的街景长什么样
    音视频开发:直播推流技术指南
    Go的闭包理解
  • 原文地址:https://blog.csdn.net/weixin_45326523/article/details/132602573
    • 最新文章
    • 攻防演习之三天拿下官网站群
      数据安全治理学习——前期安全规划和安全管理体系建设
      企业安全 | 企业内一次钓鱼演练准备过程
      内网渗透测试 | Kerberos协议及其部分攻击手法
      0day的产生 | 不懂代码的"代码审计"
      安装scrcpy-client模块av模块异常,环境问题解决方案
      leetcode hot100【LeetCode 279. 完全平方数】java实现
      OpenWrt下安装Mosquitto
      AnatoMask论文汇总
      【AI日记】24.11.01 LangChain、openai api和github copilot
    • 热门文章
    • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
      奉劝各位学弟学妹们,该打造你的技术影响力了!
      五年了,我在 CSDN 的两个一百万。
      Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
      面试官都震惊,你这网络基础可以啊!
      你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
      心情不好的时候,用 Python 画棵樱花树送给自己吧
      通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
      13 万字 C 语言从入门到精通保姆级教程2021 年版
      10行代码集2000张美女图,Python爬虫120例,再上征途
    Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
    正则表达式工具 cron表达式工具 密码生成工具

    京公网安备 11010502049817号