Parameter index out of range (2 > number of parameters, which is 1)报错,数据库语句异常,传入的参数不对,将第四行的name like concat('%','#{name}','%')改为name like concat('%',#{name},'%'),具体如下
将
<select id="selectByNameGenderTime" resultType="com.itheima.pojo.Emp">
select * from emp
<where>
<if test="name!=null and name!=''"> name like concat('%','#{name}','%')</if>
<if test="gender!=null">and gender = #{gender}</if>
<if test="begin!=null and end !=null">and entrydate between #{begin} and #{end}</if>
</where>
</select>
改为
<select id="selectByNameGenderTime" resultType="com.itheima.pojo.Emp">
select * from emp
<where>
<if test="name!=null and name!=''"> name like concat('%',#{name},'%')</if>
<if test="gender!=null">and gender = #{gender}</if>
<if test="begin!=null and end !=null">and entrydate between #{begin} and #{end}</if>
</where>
</select>