用户登录
用户注册

分享至

mybatis if ==null

  • 作者: 一抹花开c
  • 来源: 51数据库
  • 2020-09-29
<where>
<trim prefixOverrides="and">
<if test="id!=null">
and c.id=#{id}
</if>
<if test="oid!=null and oid!=0">
and b.id=#{oid}
</if>
<if test="startDate!=null">
<if test="endDate!=null">
and a.pay_time BETWEEN #{startDate} AND #{endDate}
</if>
</if>
</trim>
</where>
service层如果参数为null,mybatis执行sql语句的时候就不会去拼接你指定的if标签中的sql语句
软件
前端设计
程序设计
Java相关