当前位置: 首页 > news >正文

xml中in的使用

目录

一、简介

二、使用

1、参数为list

2、参数为Array

3、参数为Map

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


一、简介

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

<foreach  item="item" collection="list" index="index"  open="(" separator="," close=")">#{item}</foreach>

foreach的属性:

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

collection:为参数类型。

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

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

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

close:表示以什么结束

 二、使用

1、参数为list

mapper:

List<String>  selectName(List<Object> ids);

 xml:

<select id="selectName" resultType="String">select name from sys_app where  id in <foreach  item="item" collection="list" index="index"  open="(" separator="," close=")">#{item}</foreach></select>

2、参数为Array

mapper:

List<String>  selectName(String[] ids);

xml:

<select id="selectName" resultType="string">select name from sys_app where id in <foreach  item="item" collection="array" index="index"  open="(" separator="," close=")">#{item}</foreach></select>

3、参数为Map

 List<Integer> list = new ArrayList<>();list.add(1);list.add(2);Map<String,Object> map =new HashMap<>();map.put("ids",list);map.put("parms","sss");

mapper:

List<String> selecyName(Map<String,Object> map);

xml:

<select id="selectName" resultType="String">select name from sys_app where  id in <foreach  item="item" collection="ids" index="index"  open="(" separator="," close=")">#{item}</foreach></select>

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

符号原符号替换符号
小于<&lt;
小于等于<=&lt;=
大于>&gt;
大于等于>=&gt;=
不等于<>&lt;&gt;
&&amp;
单引号'&apos
双引号"&quot;

http://www.lryc.cn/news/151942.html

相关文章:

  • Unity生命周期函数
  • 【OpenCV入门】第六部分——腐蚀与膨胀
  • [C++] STL_list常用接口的模拟实现
  • js实现点击查看全部/收起功能
  • 安全区域边界技术测评要求项
  • 基于YOLOV8模型的农作机器和行人目标检测系统(PyTorch+Pyside6+YOLOv8模型)
  • 我的私人笔记(安装hbase)
  • 【MySQL】用户管理
  • 音视频 ffmpeg命令转封装
  • 恢复已删除的git分支
  • ATF(TF-A)安全通告 TFV-3 (CVE-2017-7563)
  • 虚拟机Ubuntu18.04系统使用时所需要的便利配置选项
  • python内置函数
  • 线性思维和系统思维
  • 为什么要学习C++
  • eureka服务注册和服务发现
  • QT的介绍和优点,以及使用QT初步完成一个登录界面
  • MySQL教程
  • 深入理解协同过滤算法及其实现
  • 力扣:随即指针138. 复制带随机指针的链表
  • 【从0学习Solidity】合约入门 Hello Web3
  • awtk-ftpd 发布
  • 抽象轻松的C语言
  • 【力扣每日一题01】两数之和
  • 机器学习——手写数字识别
  • 【日积月累】后端刷题日志
  • Matlab在编码中增加CRC和交织功能
  • Css 设置从上到下的渐变色: 0到70%为yellow,然后线性地变成透明。
  • git在windows上安装
  • 快速上手GIT命令,现学也能登堂入室