select role_no from t_role where 1=1<if test="roleName!=null and roleName!=''"> and role_name like concat('%',#{roleName},'%')</if>二.choose/when/otherwise实现switch...case...default逻辑三.trim/where/set1.为了避免上面的1=1,可以使用where元素:
<where><if test="roleName!=null and roleName!=''"> and role_name like concat('%',#{roleName},'%')</if></where>2.trim用于去掉and、or等语句。