<select name="typeid">
<option value="">--请选择类型--</option>
<option value="1" ${userinfo.typeid==1?"selected":""} >管理员</option>
<option value="2" ${userinfo.typeid==2?"selected":""}>经理</option>
<option value="3" ${userinfo.typeid==3?"selected":""}>普通职员</option>
</select>
mybatis的配置文件
<!--根据条件查找
判断是否为空白字符和null-->
<select id="findName" resultType="Userinfo">
select * from userinfo
<where>
<if test="username != null">
userName like concat('%',#{username},'%')
</if>
<if test="useraddress != null">
and useraddress like concat('%',#{useraddress},'%')
</if>
<if test="typeid != null and typeid != ''">
and typeid=#{typeid}
</if>
</where>
</select>
效果如下: