MyBatis报错笔记——Could not find parameter map XXX.XXX.xml
程序员文章站
2022-07-15 13:09:39
...
出错问题是 XXX-XXX.xml中相应的关键字写错了:将parameterType写错成parameterMap。这才会出错。
解决办法就是将写错的parameterMap改为parameterType
<select id="selectDynamicEmployee" resultType="com.qst.bean.Employee" parameterMap="com.qst.bean.Employee">
select * from tb_employee where 1=1
<if test="name!=null and name!=''">
and name =#{name}
</if>
<if test="gender!=null and gender!=''">
and gender =#{gender}
</if>
</select>
改为
<select id="selectDynamicEmployee" resultType="com.qst.bean.Employee" parameterType="com.qst.bean.Employee">
select * from tb_employee where 1=1
<if test="name!=null and name!=''">
and name =#{name}
</if>
<if test="gender!=null and gender!=''">
and gender =#{gender}
</if>
</select>
正常输出结果