用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错

There is no getter for property named 'sleevetype' in 'class java.lang.Integer

解决方法一:

原因在于测试条件写法有误,

        <if test="sleevetype==0"><!-- 专属 -->
exclusive=1
</if>
<if test="sleevetype!=0"><!-- 非专属 -->
sleeve_type=#{sleevetype} and exclusive=0
</if>

正确写法:

        <if test="_parameter==0"><!-- 专属 -->
exclusive=1
</if>
<if test="_parameter!=0"><!-- 非专属 -->
sleeve_type=#{sleevetype} and exclusive=0
</if>

不管传的参数是什么,都要改成"_parameter" 。

解决方法二:

是在DAO接口声明部分在形参前加上 @Param("sleevetype")

实际上,当DAO接口有多个参数时,需要使用@Param,或者用Map,或者对象。

MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer的更多相关文章

  1. 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 ...

  2. MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'

    在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的. ...

  3. mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'

    mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...

  4. Bug--Mybatis报错:There is no getter for property named 'id' in 'class java.lang.Integer'

    Mybatis 添加@Param("")注释就可以了

  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. SSM框架报错分析(一)——There is no getter for property named 'XXX' in 'class java.lang.String'

    一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType=&quo ...

  7. 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'

    mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...

  8. 已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'

    最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...

  9. 当传入数据只有一个时mybatis中<if>判断会出现There is no getter for property named 'subjectId' in 'class java.lang.Intege

    用"_parameter"代替当前参数 正确: <select id="selectSubjectByPId" parameterType="j ...

随机推荐

  1. .net程序集强命名(签名)

    要想得到强签名的dll有两种情况: 1.给项目添加强命名 在你的项目右键->属性->签名,勾选“为程序集签名”,新建 或 浏览已经新建过的.pfx文件,然后重新build项目,生成的dll ...

  2. Linux常用指令---grep(搜索过滤)

    Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...

  3. 用virtualenv管理python3运行环境

    1. 简介 virtualenv可以用来管理互不干扰的独立python虚拟环境,在有些场景下非常有用,例如: 你有两个python项目,一个是python2.7的,另一个是python3的,可以创建两 ...

  4. iOS 苹果自带地图定位Core Location

    Core Location是iOS SDK中一个提供设备位置的框架.可以使用三种技术来获取位置:GPS.蜂窝或WiFi.在这些技术中,GPS最为精准,如果有GPS硬件,Core Location将优先 ...

  5. Stack around the variable 'szStr' was corrupted.

    错误:stack around the variable “XX” was corrupted.,中文翻译就是“在变量XX周围的堆栈已损坏”. 把 project->配置属性->c/c++ ...

  6. 使用git提交本地代码到github

    1. 客户端选择 git在本地,有多种客户端可供选择,比如eclipse的插件EGit,还有git的官方客户端: Git  Bash, Git CMD, Git GUI等. 推荐使用官方的Git Ba ...

  7. 推荐一个 angular 图像加载插件

    推荐一个简单的 Angular 图片加载插件:vgSrc,插件根据图片资源的不同加载状态,显示不同图片,亲测兼容IE-8. 使用 推荐使用 bower 加载: bash bower install v ...

  8. 我的第二个app上线:术购管家

    忙了两周写完的app,终于发布了,可是等上线竟然等了两周多,今天终于上线了,一路顺畅,没有被打回过...

  9. WCF入门(8)

    前言 昨天买的usb无线路由到了,笔记本又可以愉快的上网了. 下午去办市民卡,被告知说“本人医保现在停保,要等继续缴才行”,白公交坐了那么远的路. 需要视频的进群,378190436. 第八集 Dif ...

  10. javascript继承(一)—类的属性研究

    本篇文章主要针对javascript的属性进行分析,由于javascript是一种基于对象的语言,本身没有类的概念,所以对于javascript的类的定义有很多名字,例于原型对象,构造函数等,它们都是 ...