在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的....... ,写在映射文件中完全没用,实在没办法了,找我的牛老师 ^v^ 解决一下,后来在 映射文件的对应接口的方法的参数前加注解 @Param 就解决了这个困扰了我很久的问题,解释是:如果要把传入的参数在 ‘test’ 中比较,参数前加上注解 @Param('参数名') ,如果不加注解,它将在比较时,用参数调用get方法获得值,因为不是对象,所以也就报错了,我之前是用实体类包数据包装在进行传入比较的。。。。。还是记住这个坑吧。。。。。

接口代码

List<User> selectByUserState(@Param("userState") int userState);

映射文件:

    <select id="selectByUserState" parameterType="Integer" resultType="com.nf.lc.entity.User">
select * from user
<where>
<if test="userState == 1 or userState == 0">
user_state = #{userState}
</if>
</where>
</select>

希望你看到这篇博客能解决这个问题。

学无止境(LC)

MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'的更多相关文章

  1. MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer

    用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class jav ...

  2. Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'。

    Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'. 错误Li ...

  3. Mybatis报错: There is no getter for property named xxx

    在mapper文件中函数的形参上加上注解. 例如: 出现了如下错误:核心错误提示就是There is no getter for property named xxx     ### Error qu ...

  4. mybatis There is no getter for property named 'xx' in 'class java.lang.String

    转载自://http://www.cnblogs.com/anee/p/3324140.html 用mybatis查询时,传入一个字符串传参数,且进行判断时,会报 There is no getter ...

  5. 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' 一.发现问题 <select ...

  6. mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long'

    mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long' 当使用mybatis进行传参的时候 ...

  7. Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'

    错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  8. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'socialCode' in 'class java.lang.String'

    异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Refl ...

  9. Mybatis问题:There is no getter for property named 'unitId' in 'class java.lang.String'

    Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.re ...

随机推荐

  1. 实现迭代器(\_\_next\_\_和\_\_iter\_\_)

    目录 实现迭代器(__next__和__iter__) 一.简单示例 二.StopIteration异常版 三.模拟range 四.斐波那契数列 实现迭代器(__next__和__iter__) 一. ...

  2. 5.windows-oracle实战第五课 --事务、函数

    什么是事务        事务用于保证数据的一致性,它由一组相关的dml语句组成,该组的dml语句要么全部成功,要么全部失败. 事务和锁        当执行一个事务dml的时候,oracle会被作用 ...

  3. 吴裕雄--天生自然 PYTHON3开发学习:日期和时间

    import time; # 引入time模块 ticks = time.time() print ("当前时间戳为:", ticks) import time localtime ...

  4. dbgview 在windows 10 中关闭后再次打开时无法“capture kernel”

    DbgView 是一个免费的用于抓取log 的工具,可以捕获并输出OutputDebugString()函数的输出,以及输出windows driver 中dbgprint 的log,对于window ...

  5. SaltSatck常用指令一

    1.查看版本号: salt --version [root@master ~]# salt --version salt (Fluorine) [root@master ~]# 2.显示依赖关系及版本 ...

  6. tensorflow(四)

    tensorflow数据处理方法, 1.输入数据集 小数据集,可一次性加载到内存处理. 大数据集,一般由大量数据文件组成,因为数据集的规模太大,无法一次性加载到内存,只能每一步训练时加载数据,可以采用 ...

  7. 900A. Find Extra One#寻找与众不同的它(计数)

    题目出处:http://codeforces.com/problemset/problem/900/A 题目大意:问删除一个点后,剩下的点能不能都在Y轴的同一边 #include<iostrea ...

  8. 用命令修改Oracle数据库密码

    1.改密码    (1).打开doc命令框键入:sqlplus /nolog     (2).输入:connect / as sysdba     (3).修改密码:alter user userNa ...

  9. iTOP4412开发板-使用buildroot搭建最简单的linux

    本文档介绍的是使用buildroot搭建最简单的linux文件系统,Buildroot是Linux平台上一个构建嵌入式Linux系统的框架.整个Buildroot是由Makefile脚本和Kconfi ...

  10. hdu2876 Connections between cities(LCA倍增)

    图不一定联通,所以用并查集找各个联通块的祖先分别建图,之后就和LCA的步骤差不多了 #include<iostream> #include<cstring> #include& ...