在使用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. 三、Oracle常用内置函数

    1. ASCII  返回与指定的字符对应的十进制数;  SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from d ...

  2. Leetcode 239.滑动窗口最大值

    滑动窗口最大值 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧.你只可以看到在滑动窗口 k 内的数字.滑动窗口每次只向右移动一位. 返回滑动窗口最大值. 示例: ...

  3. [NOIP2002] 提高组 洛谷P1033 自由落体

    题目描述 在高为 H 的天花板上有 n 个小球,体积不计,位置分别为 0,1,2,….n-1.在地面上有一个小车(长为 L,高为 K,距原点距离为 S1).已知小球下落距离计算公式为 d=1/2*g* ...

  4. BZOJ1583: [Usaco2009 Mar]Moon Mooing 哞哞叫

    给n<=4000000,c,a1,b1,c1,a2,b2,c2,以c为初始得到的数,每次可以把得到的某个数x进行操作f1(x)=a1*x/c1+b1,f2(x)=a2*x/c2+b2,求最后能得 ...

  5. php除法的知识点

    php除法的知识点 $a = 7; $b = 3; $c = $a/$b; var_dump($c);//float(2.3333333333333) //整数部分+小数点+小数部分=15位 $b = ...

  6. 洛谷—— P2812 校园网络

    P2812 校园网络 题目背景 浙江省的几所OI强校的神犇发明了一种人工智能,可以AC任何题目,所以他们决定建立一个网络来共享这个软件.但是由于他们脑力劳动过多导致全身无力身体被♂掏♂空,他们来找你帮 ...

  7. 七天从零基础学习android(1)--配置环境

    在写这篇文的时候android开发经验还是0,是一个萌新,这是一篇记录一个萌新从零android编程基础到能编写一个记账本的开发过程(至少我是这样美好的希望着的) 首先因为是没有开发基础的,直接上百度 ...

  8. JAVA实验--统计文章中单词的个数并排序

    分析: 1)要统计单词的个数,就自己的对文章中单词出现的判断的理解来说是:当出现一个非字母的字符的时候,对前面的一部分字符串归结为单词 2)对于最后要判断字母出现的个数这个问题,我认为应该是要用到ma ...

  9. Effective Java Profiling With Open Source Tools

    https://www.infoq.com/articles/java-profiling-with-open-source

  10. 一次mysql 优化 (Using temporary ; Using filesort)

    遇到一个SQL执行很慢 SQL 如下: SELECT ... FROM tableA WHERE time >= 1492044535 and time <= 1492046335 GRO ...