mybatis String的if条件判断问题 There is no getter for property named 'xxx' in 'class Java.lang.Integer'
2018-03-08 16:20
816 查看
mybatis中if test里判断传参时,如果传参是像int的基本类型,因为它没有getter方法所以会报错:There is no getter for property named 'xxx' in 'class java.lang.Integer'
解决方法:(关于mybatis中基本类型条件判断问题 http://blog.csdn.net/cclovett/article/details/12855505)
1.修改select语句
[html] view plain copy<select id="sel_campusinfo" parameterType="int" resultType="Campusinfo">
select cmpid,cmpname from campusinfo where state!='d' and cmpid!=0
<if test="_parameter!=0">and cmpid=#{_parameter}</if>
</select>
参数名全部改为_parameter。
2.不修改sql,只修改接口接口类:[java] view plain copyCampusinfo sel_campusinfo( int cmpid);
改为:[java] view plain copyCampusinfo sel_campusinfo(@Param(value="cmpid") int cmpid);
3.可以将参数包装在hashmap或者对象中作为参数
解决方法:(关于mybatis中基本类型条件判断问题 http://blog.csdn.net/cclovett/article/details/12855505)
1.修改select语句
[html] view plain copy<select id="sel_campusinfo" parameterType="int" resultType="Campusinfo">
select cmpid,cmpname from campusinfo where state!='d' and cmpid!=0
<if test="_parameter!=0">and cmpid=#{_parameter}</if>
</select>
参数名全部改为_parameter。
2.不修改sql,只修改接口接口类:[java] view plain copyCampusinfo sel_campusinfo( int cmpid);
改为:[java] view plain copyCampusinfo sel_campusinfo(@Param(value="cmpid") int cmpid);
3.可以将参数包装在hashmap或者对象中作为参数
相关文章推荐
- mybatis 基本类型的if条件判断问题 There is no getter for property named 'xxx' in 'class Java.lang.Integer'
- 关于Mybatis "There is no getter for property named 'XXX' in class java.lang.String"的问题
- Mybatis异常There is no getter for property named 'XXX' in 'class java.lang.String
- Mybatis-There is no getter for property named 'XXX' in 'class java.lang.String'解决办法
- Mybatis异常There is no getter for property named 'XXX' in 'class java.lang.String'
- MyBatis报错:There is no getter for property named 'xxx' in 'class java.lang.String'
- Mybatis问题:There is no getter for property named 'unitId' in 'class java.lang.String'
- Mybatis问题:There is no getter for property named 'Id' in 'class java.lang.String'
- Mybatis 对单独传入参数string进行判断时报There is no getter for property named '**' in 'class java.lang.String解决办法
- Mybatis异常There is no getter for property named 'XXX' in 'class java.lang.String'
- 当传入数据只有一个时mybatis中<if>判断会出现There is no getter for property named 'subjectId' in 'class java.lang....
- MyBatis There is no getter for property named 'xxx' in 'class java.lang.String'
- MyBatis There is no getter for property named 'xxx' in 'class java.lang.String'
- Mybatis问题:There is no getter for property named 'VALUE' in 'class java.lang.String'
- mybatis错误:There is no getter for property named 'xxx' in 'class java.lang.String'
- mybatis加Spring项目: 解决There is no getter for property named '***' in 'class java.lang.String'问题
- mybatis:There is no getter for property named 'xxx' in 'class java.lang.String'
- mybatis出现There is no getter for property named 'XXX' in 'class java.lang.String'错误
- Mybatis-There is no getter for property named 'id' in 'class java.lang.String'
- mybatis报错 There is no getter for property named 'xx' in 'class java.lang.String