Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxxx
程序员文章站
2022-07-15 13:46:12
...
在mybatis的映射传参,只能传入一个。通過 #{变量名} 即可获取传入的值。
public int delete(int id) throws Exception;
<delete id="delete" parameterType="int">
delete from user where id=#{id}
</delete>
接口定义了delete(int id),形参变量名id。 在sql就用#{id}去获取。
其实这里的”引用名”可以任意。JAVA反射只能获取方法类型,无法知道变量名。上面這個例子把#{id}換成#{di},一樣執行。當然為了便於閱讀程式碼,還是用#{id}。
_parameter則是java對通過反射獲取引數後,給引數取的別名。所以用#{_parameter}也行。
好了抄的网上的一般方案,再看看我的问题到底在哪。其实也没啥,就是 xml 里变量名写错了。将 mysql 数据表里的字段当成了 java 类里的字段了。
上一篇: Mybatis报错:There is no getter for property named 'xxxx' in 'class xxxx
下一篇: Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxxx
推荐阅读
-
Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxxx
-
Mybatis报错:There is no getter for property named 'xxxx' in 'class xxxx
-
Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxxx
-
Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxxx
-
There is no getter for property named 'xxx' in 'class java.lang.xxxx'解决办法
-
Mybatis There is no getter for property named 'xxxx' in 'class java.lang.String'
-
Mybatis There is no getter for property named 'XXX' in 'class java.lang.XXX
-
Mybatis报错:There is no getter for property named 'xxxx' in 'class xxxx
-
Mybatis中传参包There is no getter for property named 'XXX' in 'class java.lang.Strin
-
Mybatis-There is no getter for property named 'id' in 'class java.lang.String'