问题代码 <if test="userRole != null and userRole != ''"> and a.userRole = #{userRole} </if> 发现问题 userRole为0时,被userRole != ‘’ 过滤了。 而且userRole本来就是Integer类型,不需要!= ‘’