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