Mybatis运行时出现There is no getter for property named 'xxx' in 'class java.lang.String'错误
使用smm框架查询数据时,mybatis出现问题。
这里使用的是mybatis3.4.3版本
一、报错分析
1、显示没有cardNumber这个属性2、OGNL表达式出现问题
二、原因分析。
Mybatis默认采用*OGNL解析参数,所以会自动采用对象树的形式取 string.xxx 值,如果没在在方法中定义,则会抛异常报错。
三、解决方案(基于ssm框架)
- 1、在对应的持久层的接口中加入@Param(value = “xxx”) String xxx)注解。
Student getStudentByCardNumber(@Param(value = "cardNumber") String cardNumber);
- 2、尝试修改mybatis版本。(未测试过)