1. 程式人生 > >mybatis入門截圖三

mybatis入門截圖三

style result span parameter jpg log class es2017 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 也不會報錯。

mybatis入門截圖三