myBatis的bind的标签,一般的用法都是

<if test="name!= null and name!= '' ">
  <bind name="userLike" value=" '%' + name+ '%' "/>
  and user_name like #{userLike}
</if>

  

但是,当bind和OGNL结合使用时,用处还是大大的

ognl的用法借用这位的文章 https://www.cnblogs.com/wgj-master/p/7891289.html

MyBatis常用的OGNL

e1 or e2
e1 and e2
e1 == e2,e1 eq e2
e1 != e2,e1 neq e2
e1 lt e2:小于
e1 lte e2:小于等于,其他gt(大于),gte(大于等于)
e1 in e2
e1 not in e2
e1 + e2,e1 * e2,e1/e2,e1 - e2,e1%e2
!e,not e:非,求反
e.method(args)调用对象方法
e.property对象属性值
e1[ e2 ]按索引取值,List,数组和Map
@class@method(args)调用类的静态方法
@class@field调用类的静态字段值

  

例:

  <bind name="xxx"  value="@com.xx.mybaits.Abc@aa(item, 'a','b')"/>

这里xxx为bind的名字,item为mapper传递的参数,后面为传的字符串

通过bind,我们可以通过java代码设置自定义的值,也可以进行一些判断,如果不符合判断,抛出异常,还是很灵活的

Myatis之bind标签的更多相关文章

  1. Myatis中的OGNL和bind标签的结合用法

    1.MyBatis常用的OGNL e1 or e2 e1 and e2 e1 == e2,e1 eq e2 e1 != e2,e1 neq e2 e1 lt e2:小于 e1 lte e2:小于等于, ...

  2. Mybatis学习笔记16 - bind标签

    1.${}拼串进行模糊查询,不安全 示例代码: 接口定义: package com.mybatis.dao; import com.mybatis.bean.Employee; import java ...

  3. MyBatis bind标签的用法

    From<MyBatis从入门到精通> <!-- 4.5 bind用法 bind标签可以使用OGNL表达式创建一个变量并将其绑定到上下文中. 需求: concat函数连接字符串,在M ...

  4. mybatis bind标签

    开门见山的说,平时写模糊查询,一直用${name},例如: select * from table where name like '%${name}%' 后来知道了,这样写可能会引发sql注入,于是 ...

  5. mybatis bind 标签

    bind 标签可以使用 OGNL 表达式创建一个变量井将其绑定到上下文中.在前面的例子中, UserMapper.xml 有一个 selectByUser 方法,这个方法用到了 like 查询条件,部 ...

  6. mybaits模糊查询使用<bind>标签

    <select id="selectBlogsLike" resultType="Blog"> <bind name="patter ...

  7. mybaitis动态sql利用bind标签代替%拼接完成模糊查询

    Oracle中使用bind的写法 <select id="selectUser" resultType="user" parameterType=&quo ...

  8. bind标签_databaseId标签,_parameter标签的使用

    1.在接口写方法 public List<Employee> getEmpsTestInnerParameter(Employee employee); 2在映射文件中进行配置 <s ...

  9. bind 标签

    <select id="finduserbylikename"  parameterType="string"  resultMap="cour ...

随机推荐

  1. Ubuntu下GDB调试器的使用

    gdb调试器时一款GNU组织开发.发布的UNIX/Linux环境下的程序调试工具,没有图形界面,但功能强大. GDB使用流程: 先编写一个测试文件gdbTest.c 保存后用gcc对文件进行编译,需要 ...

  2. markdown中如何设置字体为红色?

    答: 语法如下: <font color='red'> text </font>

  3. 扯扯python的多线程的同步锁 Lock RLock Semaphore Event Condition

    我想大家都知道python的gil限制,记得刚玩python那会,知道了有pypy和Cpython这样的解释器,当时听说是很猛,也就意味肯定是突破了gil的限制,最后经过多方面测试才知道,还是那德行… ...

  4. 阶段5 3.微服务项目【学成在线】_day16 Spring Security Oauth2_08-SpringSecurityOauth2研究-解决swagger-ui无法访问

    3.3.4.4 解决swagger-ui无法访问 当课程管理加了授权之后再访问swagger-ui则报错: 这里默认配置的了所有的请求都必须认证 把图片认证的路径加进去的话 那么访问课程图片的列表 就 ...

  5. 123456123456#0#-----com.threeapp.xiongMaoPaoPao01----熊猫跑酷01

    com.threeapp.xiongMaoPaoPao01----熊猫跑酷01

  6. 浏览器最小显示12px字体的解决方法

    今天做打印标签,发现浏览器最小字体限制了12px,标签那么小,12px随便几个字就给占满了: 最后通过  transform:scale(1,0.8) 搞定: 这个属性允许将元素移动.压缩.旋转:这里 ...

  7. Java中使用队列Queue

    示例代码: Queue<Integer> queue = new LinkedList<Integer>(); for (int i = 1; i <= 100; i + ...

  8. 【Leetcode_easy】804. Unique Morse Code Words

    problem 804. Unique Morse Code Words solution1: class Solution { public: int uniqueMorseRepresentati ...

  9. 【c# 学习笔记】封装

    封装 指的是把类内部的数据隐藏起来,不让对象实例直接对其操作.c#中提供了属性机制来对类内部的状态进行操作. 在c#中,封装可以通过Public.Private.Protected和Internal等 ...

  10. 如何实现批量截取整个网页完整长截图,批量将网页保存成图片web2pic/webshot/screencapture/html2picture

    如何实现批量截取整个网页完整长截图,批量将网页保存成图片web2pic/webshot/screencapture [困扰?疑问?]: 您是否正受到:如何将网页保存为图片的困扰?网页很高很长截图截不全 ...