当mybatis有多个参数时,mapper.java文件即dao层必须写上@Param注解
List<AddressBean> listAddressByDate(@Param("startDate")String startDate, @Param("endDate")String endDate);
然后在xml文件里用where if判断是否为空,注意if的test判断里不要加#{ }
<select id="listAddressByDate" resultType="cn.zwkj.beans.AddressBean" parameterType="String">
select biaozhunmingcheng,hanyuduyin,dzzzcode,dengjishijian,id from t_placecommon
<where>
<if test="startDate!=null and startDate != '' ">
and to_char(dengjishijian,'yyyy-MM-dd') <![CDATA[>=]]> #{startDate}
</if>
<if test="endDate!=null and endDate != '' ">
and to_char(dengjishijian,'yyyy-MM-dd') <![CDATA[<=]]> #{endDate}
</if>
</where>
</select>