org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'requestMap.cpmodel != null and requestMap.cpmodel != '''. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "cpmodel")

问题出现的愿意:我在mapper.xml中的查询方法中<if></if>中的test里使用了requestMap

代码如下:

<select id="countdoid" resultMap="detailsout">
            select count(doid) from details_out,orders_need_supplyofgoods_details,position,orders_need,product,customer
            where orders_need_supplyofgoods_details.status != 6
            AND details_out.positionid = position.positionid
            AND orders_need_supplyofgoods_details.nid = orders_need.nid
            AND orders_need.cpid = product.cpid
            AND position.cid = customer.cid
            AND details_out.onsdid = orders_need_supplyofgoods_details.onsdid
             <if test="requestMap.cpmodel != null and requestMap.cpmodel != ''">
                AND product.cpmodel = #{requestMap.cpmodel}
            </if>
            <if test="requestMap.cname != null and requestMap.cname != ''">
                AND customer.cname = #{requestMap.cname}
            </if>
            <if test="requestMap.weiyibiaoshi != null and requestMap.weiyibiaoshi != ''">
                AND orders_need_supplyofgoods_details.weiyibiaoshi = #{requestMap.weiyibiaoshi}
            </if>
            <if test="requestMap.status != null and requestMap.status != ''">
                AND orders_need_supplyofgoods_details.status = #{requestMap.status}
            </if>
    </select>

问题解决:我在mapper层中的方法里没有添加@Param("requestMap")Map<String, Object> requestMap,

解决方法:

  /**
     *
     * @Title: countdoid
     * @Description: TODO(物资闲置,计算已分发物资的数量)
     * @return
     */
    int countdoid();

添加参数后为

/**
     *
     * @Title: countdoid
     * @Description: TODO(物资闲置,计算已分发物资的数量)
     * @return
     */
    int countdoid(@Param("requestMap")Map<String, Object> requestMap);

这样在mapper.xml的语句中就不会出问题了

source is null for getProperty(null, "cpmodel")异常结局的更多相关文章

  1. root cause org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "XXX")

    在执行一个查询语句的时候,mybatis报错:root cause org.apache.ibatis.ognl.OgnlException: source is null for getProper ...

  2. org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "enterpCd")-Mybatis报错

    一.问题由来 下午快要下班时,登录测试服务器查看日志信息,看看有没有新的异常信息,如果有的话好及时修改.结果一看果然有新的异常信息. 主要的异常信息如下: 2020-10-13 14:51:03,03 ...

  3. Caused by: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "mil_id")

    今天在使用mybatis处理数据库的时候,突然抛出了上述异常,让我感到很惊讶,因为在处理save的时候,在Mybatis的配置文件中,我根本就没有使用到ognl表达式,系统怎么会抛出上述异常.而且之前 ...

  4. 解决 Illegal DefaultValue null for parameter type integer 异常

    该异常是由 swagger 引起的 swagger 版本 1.9.2 解决原因:重新导入 swagger-annotations 和 swagger-models 版本 为 1.5.21 pom.xm ...

  5. Python使用import导入模块时报ValueError: source code string cannot contain null bytes的解决方案

    老猿在导入一个Python模块时报错: >>> import restartnet.py Traceback (most recent call last): File " ...

  6. ognl.OgnlException: target is null for setProperty(null, "emailTypeNo", [Ljava.lang.String;@1513fd0)

    [com.opensymphony.xwork2.ognl.OgnlValueStack] - Error setting expression 'emaiTypeDto.emailTypeNo' w ...

  7. 原!! java直接打印一个对象时,并不是直接调用该类的toString方法 ,而是会先判断是否为null,非null才会调用toString方法

    网上看了好多java直接打印一个对象时,直接调用该类的toString方法 . 但是: Object obj=null; System.out.println(obj);//没有报错 System.o ...

  8. 关于ognl.OgnlException: target is null for setProperty(null的解决方案

    在跑struts2的时候有时候会出现上面的错,特别是新手, 这种情况是在struts2高级的POJO访问时候出现的s 警告: Error setting expression 'user.passwo ...

  9. 了不起的 “filter(NULL IS NOT NULL)”

    经常会在执行计划中看到很奇怪的"FILTER"操作,然后看对应的执行信息是"filter(NULL IS NOT NULL)".  其实这是优化器非常聪明的“短 ...

随机推荐

  1. mySQL、mariaDB、noSQL、SQL server、redis之间是什么关系?

    1.首先,从数据库类型上分类,mySQL.mariaDB.SQL server这3种属于关系型数据库. noSQL属于非关系型数据库,被视为数据库革命者. redis成为内存缓存数据库,而前面的两种类 ...

  2. 【JDK1.8】Java 8源码阅读汇总

    一.前言 ​ 万丈高楼平地起,相信要想学好java,仅仅掌握基础的语法是远远不够的,从今天起,笔者将和园友们一起阅读jdk1.8的源码,并将阅读重点放在常见的诸如collection集合以及concu ...

  3. java内部类demo

    内部类主要有三种:静态内部类,实例内部类,局部变量内部类 1.静态内部类,该类被static修饰,并且是成员变量,它只能访问外部类被static修饰的方法以及字段(这种说法只局限于不再内部类中创建外部 ...

  4. 数据库中有的字段为null时,反馈到页面上是什么也不显示?如何用一个【无】字来代替呢?

    <asp:ListView ID="listViewCustomer" DataSourceID="ods_Customer" runat="s ...

  5. gnome 3 美化

    首先,去http://gnome-look.org/找到需要的主题,然后手动安装或者用下载到的主题包里的脚本安装 手动安装对应路径如下: 鼠标,图标主题解压放置:~/.icons或/usr/share ...

  6. SVN.服务器迁移方法

    SVN项目, 源服务器  : 10.10.13.48 目标服务器: 10.10.13.129 要把SVN项目从.48上迁移到.129上. 做法: 准备: 版本库:vos 源服务器  : 10.10.1 ...

  7. typeof、constructor和instance

    在JavaScript中,我们经常使用typeof来判断一个变量的类型,使用格式为:typeof(data)或typeof data.typeof返回的数据类型有六种:number.string.bo ...

  8. Java基础笔记5

    方法(函数) 就是一块可以重复调用的代码块. 比如.100行代码. 在多处使用. 方法的格式 public static 返回类型 方法名称(参数列表){ } 返回类型:当方法被调用时,把返回内容 交 ...

  9. java自动化-juint框架简述

    本人使用的是java的juint框架来组织的自动化测试,故我这边需要简单介绍一下juint框架 首先,建议自行百度一下juint框架,先有一个大概的了解 所谓的接口自动化测试,会对多个接口中每一个接口 ...

  10. 利用python基于微博数据打造一颗“心”

    一年一度的虐狗节将至,朋友圈各种晒,晒自拍,晒娃,晒美食,秀恩爱的.程序员在晒什么,程序员在加班.但是礼物还是少不了的,送什么好?作为程序员,我准备了一份特别的礼物,用以往发的微博数据打造一颗&quo ...