mybatis使用${}出错
2015-11-16 14:48
281 查看
,使用${}拼接sql报错,
用的是mybatis的mapper,代码如下:
mapper:定义一个接口,参数类型为String,如果把String类型改为bean或者map都不报错
public List<UserVo> getUserInfoByStatus(String status);
xml:把xml文件中的'${status}'改为#{status}也不报错
<select id="getUserInfoByStatus" resultType="UserVo" parameterType="String">
<![CDATA[
select * from bp_lvwang_user t where t.homegw = '0' and t.status = '${status}'
]]>
</select>
报错信息:
Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException:
There is no getter for property named 'status' in 'class java.lang.String'
解决方法:
有两种解决方法:
1.public List<UserVo> getUserInfoByStatus(@Param(value="status") String status);
2.select * from bp_lvwang_user t where t.homegw = '0' and t.status = '${value}'
用的是mybatis的mapper,代码如下:
mapper:定义一个接口,参数类型为String,如果把String类型改为bean或者map都不报错
public List<UserVo> getUserInfoByStatus(String status);
xml:把xml文件中的'${status}'改为#{status}也不报错
<select id="getUserInfoByStatus" resultType="UserVo" parameterType="String">
<![CDATA[
select * from bp_lvwang_user t where t.homegw = '0' and t.status = '${status}'
]]>
</select>
报错信息:
Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException:
There is no getter for property named 'status' in 'class java.lang.String'
解决方法:
有两种解决方法:
1.public List<UserVo> getUserInfoByStatus(@Param(value="status") String status);
2.select * from bp_lvwang_user t where t.homegw = '0' and t.status = '${value}'
相关文章推荐
- latex参考文献
- 一个苹果证书如何多次使用——导出p12文件
- 创业这10种死法,你死在哪一种了
- oracle正则表达式函数 substr instr简单分析
- MyEclipse快捷键大全
- Tomcat生成https+ssl双向证书认证(jdk)
- base64加、解密实现方法
- Ceph RBD终端连接方案
- ADB and linux命令
- Android中自定义仿IOS回弹效果的ListView
- 屏幕适配相关知识点
- mysql学习——DATE_SUB()&EXTRACT() 函数
- 今天搞明白了内些传说中的硬件
- 各js取值。
- 免费的编程中文书籍索引
- PHP大神的十大优良习惯
- ASP.NET图片上传实例(附源码)
- MySQL提供的可以计算两个时间间隔的函数
- XML Publish开发--特殊字符转换
- 众数问题