There is no getter for property named 'XXX' in 'cl
2016-07-14 00:00
393 查看
一、发现问题
<select id="queryStudentByNum" resultType="student" parameterType="string">
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'。
二、解决问题
<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"。
三、原因分析
Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.num值,引起报错。也可以public List methodName(@Param(value="num") String num)的方法说明参数值
参考博客:
http://blog.sina.com.cn/s/blog_86e49b8f010191hw.html http://txin0814.iteye.com/blog/1533645
<select id="queryStudentByNum" resultType="student" parameterType="string">
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'。
二、解决问题
<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"。
三、原因分析
Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取string.num值,引起报错。也可以public List methodName(@Param(value="num") String num)的方法说明参数值
参考博客:
http://blog.sina.com.cn/s/blog_86e49b8f010191hw.html http://txin0814.iteye.com/blog/1533645
相关文章推荐
- 很不错的网站资源收集(持续更新...)
- 你需要知道的 16 个 Linux 服务器监控命令
- 从汇编代码提取Shellcode的简单实现
- 简单shellcode
- ecshop和ecstouch的insert标签的用法
- Shopxp-v10.85 CRSF攻击远程添加管理漏洞
- linux中vim编译器的使用
- ShellExecute与ShellExecuteEx的用法
- Percona-Galera-Monitoring-Template监控模板说明
- RunLoop
- Linux下安装jsoncpp
- 【poj1857】To Europe! To Europe! DP
- 监控Linux性能的18个命令行工具
- PhotoShop教程:制作玻璃水晶质感文字
- Linux中的可用内存指的是什么?
- 透明ico图标制作方法
- 利用IIS日志追查网站入侵者
- python与shell通过微信企业号发送消息
- error LNK2001: unresolved external symbol __imp__fopen
- Makefile详解