在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名。

正确的写法:

  1. <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 -->
  2. <select id="isCargoBillNoExist" resultType="java.lang.Integer">
  3. select count(1)
  4. from t_entry_cargo_receiver_info
  5. where 1=1
  6. <if test="_parameter != null" >
  7. and cargo_bill_no = #{<span style="color:#ff0000;">_parameter</span>,jdbcType=VARCHAR}
  8. </if>
  9. </select></span>

错误的写法:

  1. <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 -->
  2. <select id="isCargoBillNoExist" resultType="java.lang.Integer">
  3. select count(1)
  4. from t_entry_cargo_receiver_info
  5. where 1=1
  6. <if test="id != null" >
  7. and cargo_bill_no = #{<span style="color:#ff0000;">id</span>,jdbcType=VARCHAR}
  8. </if>
  9. </select></span>

评论区有人提到:

也可以在mapper的接口中,给这个方法的参数加上@param(value=“id”),这样就能在.xml中使用#{id,jdbcType=VARCHAR} 了。

这样也是可以的。

===============分割线===============

不过本文提到的错误,在实践中发现,并不都会出现。可能跟mybatis的版本有关系,就是说按照上文"错误"的写法来写,在某些版本中也是没有问题的,不必纠结。

如果出现了标题的错误,按照文中的方式解决即可。

示例:

mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.String'的更多相关文章

  1. 关于mybtis 使用过程中发生There is no getter for property named 'id' in class 'java.lang.String' 错误

    今天在修改一个关于mybtis语句时,偶然发现的一个错误  There is no getter for property named 'id' in class 'java.lang.String' ...

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

  3. Mybatis-There is no getter for property named 'id' in 'class java.lang.String'

    <mapper namespace="cn.telchina.standard.mapper.SysOrgnMapper"> <!-- <![CDATA[s ...

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

    https://blog.csdn.net/u011897392/article/details/46738747 使用mybatis传入参数,如果在mappin.xml中使用<if>标签 ...

  5. mybaits错误解决:There is no getter for property named 'parentId ' in class 'java.lang.String'

    在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 比如mapper中如下方法,只有一个String值 publ ...

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

  7. 已解决: 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 ...

  8. There is no getter for property named 'userId' in 'class java.lang.String'

    [ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerEx ...

  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. [luoguP1866]滑动窗口(单调队列)

    传送门 可以搞2个单调队列. 然后,然后就没有然后了. # include <iostream> # include <cstdio> # include <cstrin ...

  2. 新版VS-code如何自动换行?

    文件  -> 首选项 -> 设置 -> 编辑器 找到 // 控制折行方式.可以选择: - "off" (禁用折行), - "on" (视区折行 ...

  3. 【2018 Multi-University Training Contest 5】

    01: 02:https://www.cnblogs.com/myx12345/p/9436953.html 03: 04: 05:https://www.cnblogs.com/myx12345/p ...

  4. 【NOIP模拟&POJ2152】灰色的果实(树形DP)

    题意: Nebula 历 2014 年 12 月 17 日,欢迎来到异世界. 面对截然不同的新世界,你决定采取最普通但最为有效的方式来探索,那便 是徒步.准备好营地的一切,你开始了探索的旅程. 步行大 ...

  5. 【ZJOI2017 Round1练习】

    喜闻乐见(爆蛋滚粗)的ZJOI模拟赛终于开始了 可以又一次感受被屠的快感 DAY1: T1:线段树打错-70 正解分块听卡常还要调块的大小 T2:数学弱爆 是道结论题 T3:暴力分滚粗 DAY2: T ...

  6. 给你两个字符串str1,str2,找出str2在str1中的位置

    如题 题目参考链接: http://blog.csdn.net/hxz_qlh/article/details/14110221 代码来自非原创 #include <iostream> # ...

  7. POJ 1062 【带约束的最短路问题】

    中文题题意不写. 建图: 我自己想到的建图方式是把每个物品看作两个点,编号分别是i和i+n,然后每个物品两个点之间边的权值是物品本身的价值.然后从第i个点往外连边,目标是可替代品顶点编号较小的点,权值 ...

  8. Atom安装Markdown编辑器

    1.安装插件 2.打开/关闭实时渲染: [Ctrl]+[Shift]+[M] 3.[增强]安装同步滚动插件(markdown-scroll-sync) 4.[增强]安装代码增强插件(language- ...

  9. Ubuntu 16.04关闭Alt+鼠标左键移动窗口(转)

    1.打开终端,菜单-编辑-配置文件首选项-命令,勾上“以登录Shell方式运行命令”,重启终端. 2.在终端输入 gsettings get org.gnome.desktop.wm.preferen ...

  10. 关于MSSQL的decimal(numeric)、money、float的使用以及区别

    decimal(numeric).money.float(real) 都是MSSQL中的浮点类型的数据类型. 按存储的范围进行排序 float(real) decimal(numeric) money ...