mybatis
1.ognl表达式
$表示引用,#表示取值,%表示取传入字符串的值,@表示执行静态方法,去集合中数据 list[0],定义list {1,2,3,4,5},去map中数据 map[key], 定义map {"a":"1"}
基本四则运算和比较运算
投射
Person p1 = new Person(1, "11"); Person p2 = new Person(2, "22"); Person p3 = new Person(3, "33"); ArrayList<Person> list = new ArrayList<Person>(); list.add(p1); list.add(p2); list.add(p3); #list.{id} // [1,2,3] #list.{name} // ["11","22","33"] #list.{? #this.id > 2} // [{3,"33"}] #list.{^ #this.id > 1} //id>1的第一个 // [{2,"22"}] #list.{$ #this.id > 1} //id>1的最后一个 // [{3,"33"}]
创建对象 new 全类名()
2.标签
if 判断,true则执行其中内容
<if test="id != null"> and id=#{id} </if>
choose when otherwise
choose 的使用很像 Java 中的 switch 语法,当满足第一个 when 条件时,就不去看后续的条件,如果条件都不满足,则执行 otherwise
trim
select * from user <trim prefix="where" prefixOverrides="or"> <if test="a != null"> or a=#{a} </if> <if test="b != null"> or b=#{b} </if> </trim>
where
<select id="demo"> select * from tb <where> <if test="a != null"> and a=#{a} </if> <if test="b != null"> and b=#{b} </if> </where> </select>
会自动去除where条件内第一个 and 或者or
set功能与where类似,但是set是在开头加上set关键字
foreach 循环
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2020-03-30 角色标注