错误信息:Nested exception is org.apache.ibatis.binding.bindingException:parameter inVo not found
java
public interface UserMapper{
//查询用户列表
User queryUserList(@Param ("inVo") UserInVo userInVo);
}
对应的UserMapper如下:
sql
<select id="queryUserList" returnType="User">
selelct id,name,age,phone,createtime from tb_user A
<where>
<if test="inVo.name!='' and inVo.name!=null">
A.name=#{inVo.name}
</if>
<if test=" userInVo.age!=null">
A.age=#{userInVo.age}
</if>
</where>
order by A.createtime desc
</select>
原因 :mappper 的接口方法中,因为使用@Param注解,重命名入参,但是SQL中没有使用重命名的参数名导致
改正:SQL使用重命名后的参数名
sql
<select id="queryUserList" returnType="User">
selelct id,name,age,phone,createtime from tb_user A
<where>
<if test="inVo.name!='' and inVo.name!=null">
A.name=#{inVo.name}
</if>
//错误改正:userInVo改正为:inVo
<if test=" inVo.age!=null">
A.age=#{inVo.age}
</if>
</where>
order by A.createtime desc
</select>