模糊查询
<sql id="where_case"><if test="username!=null and username != ''">and username like concat('%',#{username},'%')</if><if test="userrole!=null">and userrole=#{userrole} </if></sql>
#{ }预编译SQL语句 ${ }拼接SQL语句
模糊查询
<sql id="where_case"><if test="username!=null and username != ''">and username like concat('%',#{username},'%')</if><if test="userrole!=null">and userrole=#{userrole} </if></sql>