記一次mybatis<if>標簽的問題
阿新 • • 發佈:2019-05-17
apache ont pre 保持 mage com exc inf www.
前言
到底還是沒理解清楚的鍋~~~~搞了好久。。。啊啊啊啊
錯誤:
There is no getter for property named ‘name‘ in ‘class java.lang.Long‘
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘name‘ in ‘class java.lang.Long‘
xml
dao層
分析:
傳值的時候,mybatis不知道這個值時傳給誰(id、name);索性就把這個id值給了id和name
解決方式:
保持sql不變,在dao層把參數換成map類型:
dao層
這樣子,只要後臺controller調用(service)方法時,只要params.put("id","xxx");params.put("name","xxx");
這樣就分清傳誰給誰。
參考文章:https://www.cnblogs.com/gmq-sh/p/5624781.html 寫得很不錯!
記一次mybatis<if>標簽的問題