使用smm框架查询数据时,mybatis出现问题。


这里使用的是mybatis3.4.3版本

一、报错分析


1、显示没有cardNumber这个属性Mybatis运行时出现There is no getter for property named 'xxx' in 'class java.lang.String'错误2、OGNL表达式出现问题Mybatis运行时出现There is no getter for property named 'xxx' in 'class java.lang.String'错误

二、原因分析。

Mybatis默认采用*OGNL解析参数,所以会自动采用对象树的形式取 string.xxx 值,如果没在在方法中定义,则会抛异常报错。

三、解决方案(基于ssm框架)

  • 1、在对应的持久层的接口中加入@Param(value = “xxx”) String xxx)注解。
    Student getStudentByCardNumber(@Param(value = "cardNumber") String cardNumber);
  • 2、尝试修改mybatis版本。(未测试过)

相关文章:

  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2021-11-03
  • 2021-10-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2021-07-04
相关资源
相似解决方案