There is no getter for property named 'XXX' in 'cl

1、發現問題html

<select id="queryStudentByNum" resultType="student" parameterType="string">  java

select num,name,phone from student  
<where> 
<if test = " num!=null and num!='' ">
AND num = #{num}
</if>
</where>
</select> 
Mybatis查詢傳入一個字符串傳參數,報There is no getter for property named 'num' in 'class java.lang.String'。


 spa

2、解決問題htm

<select id="queryStudentByNum" resultType="student" parameterType="string">  對象

select num,name,phone from student  
<where> 
<if test = " _parameter!=null and_parameter!='' ">
AND num = #{_parameter}
</if>
</where>
</select>
不管參數名,都要改爲"_parameter"。


 blog

3、緣由分析字符串

Mybatis默認採用ONGL解析參數,因此會自動採用對象樹的形式取string.num值,引發報錯。也能夠public List methodName(@Param(value="num") String num)的方法說明參數值get

 

參考博客:博客

http://blog.sina.com.cn/s/blog_86e49b8f010191hw.htmlstring

http://txin0814.iteye.com/blog/1533645

相關文章
相關標籤/搜索