mybatis入门截图三
Posted 乔克叔叔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis入门截图三相关的知识,希望对你有一定的参考价值。
-----------------------------------------------
<!-- 用户信息的综合查询 --> <select id="userlist" parameterType="org.mybatis.po.UserQueryVo" resultType="org.mybatis.po.UserCustom"> <!-- 原来的sql --> <!-- select *from user where user.sex=#{userCustom.sex} and user.username like \'%${userCustom.username}%\' --> <!-- 动态sql --> select *from user <where> <if test="userCustom!=null"> <if test="userCustom.sex!=null and userCustom.sex!=\'\'"> and user.sex=#{userCustom.sex} </if> <if test="userCustom.username!=null and userCustom.username!=\'\'"> and user.username=#{userCustom.username} </if> </if> </where> </select>
这样在传入参数时,传递null 也不会报错。即sql语句没有where条件 查询所有
------------------------------------------
-------------------------
以上是关于mybatis入门截图三的主要内容,如果未能解决你的问题,请参考以下文章