某次运行以后出现了映射问题
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘c_class’ in ‘class java.lang.String’,获取不到单个的传入值,产生的原因还未发现
经过排查以后发现问题出现在xml文件中
原本:
<select id="selectStudentListCount" parameterType="String" resultType="Integer">
select count(*) from t_student
<where>
<if test="c_class!=null and c_class !=''">
c_class=#{c_class}
</if>
</where>
</select>
DAO:public Integer selectStudentListCount(String c_class);
当注释了if语句以后,程序运行正常。
解决办法:
1.将c_class包装在类中,通过set传入其中(√)
2.或者将if语句改为<if test="_parameter!=null and _parameter !=''">
(√)
3.或者将DAO中的语句更改为
public Integer selectStudentListCount(@Param(“c_class”)String c_class);(√)