异常:nested exception is org.apache.ibatis.binding.BindingException: Parameter 'testypid' not found. Available parameters are [ztpsXmjcxx, pageable, param1, param2]
分析:以为是xml文件中没有对应的字段,一细看了几遍是有这个字段的,而且entity也有这个字段。查询xml中的sql语句,定位到是
<if test="testypid != null and testypid != ''">
and testypid = #{testypid}
</if>
这一段导致的异常,于是打断点,实体类中是传入了字段的值,那么分析可能是因为mapper里面传入了2个实体类的参数,导致筛选的时候 if里面获取不到实体类里面的字,再回到mapper里面的方法
mapper对应的方法
List<ZtpsXmjcxx> queryAllByLimit(mjcxx mjcxx, @Param("pageable") Pageable pageable);
发现 ztpsXmjcxx 实体类前面 没有@Param
mapper文件修改后
List<ZtpsXmjcxx> queryAllByLimit(@Param("mjcxx")mjcxx mjcxx, @Param("pageable") Pageable pageable);
xml文件修改后
<if test="mjcxx.post1 != null and mjcxx.post1 != ''">
and mjcxx.testypid = #{mjcxx.testypid}
</if>