mybatis:映射问题There is no getter for property named 'c_class' in 'class java.lang.String'

博客讲述了某次运行后出现MyBatis映射问题,获取不到单个传入值,错误信息为org.apache.ibatis.reflection.ReflectionException。经排查,问题出在xml文件中。注释if语句后程序正常,并给出三种解决办法,如将参数包装在类中、修改if语句、在DAO语句中使用@Param注解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

某次运行以后出现了映射问题
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);(√)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值