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. [js高手之路]匀速运动与实例实战(侧边栏,淡入淡出)

    javascript中,如何让一个元素(比如div)运动起来呢? 设置基本的样式,一定要让div有定位( 当然用margin的变化也可以让元素产生运动效果 ); <style> div { ...

  2. winPcap编程之获取适配器详细信息(三)

    显示适配器详细信息 先贴上代码 #include <stdio.h> #include <stdlib.h> #include <string.h> #includ ...

  3. java连接sqlserver2008r2 心得

    现在是该轻松一笑的时候了,困扰已久的问题有了解释了. 之前的各种连不上,说到底还是权限问题,sqlserver2008r2的权限分得太细了. 两个实例间数据库互相都看不到,更不用谈访问了. 端口号也是 ...

  4. Html 初识样式表&选择器

    样式表&类选择器分类 样式表分类: 1.内联式样式表:在标签内部写样式代码,精确但不方便,增加工作量,后期修改麻烦. 2.嵌入式样式表:一般写在head内 以<style>.... ...

  5. sublime addons backup

    1.you can create a file to store you installed addons and use git to store github.com just like that ...

  6. Selenium 设置浏览器下载 Firefox 和Chrome

    当我们在使用Selenium运行自动化测试时,偶尔需要用到下载功能,但浏览器的下载可能会弹出下载窗口,或者下载路径不是我们想要保存的位置,所以在通过Selenium启动浏览器时需要做相关的设置,将使这 ...

  7. 南天PR2、PR2E驱动下载,xp,win7,win8,win8.1,win10 32位64位驱动下载安装教程

    家里开淘宝店,有个针式打印机驱动.电脑各种换系统,为了装这个驱动可是废了不小的劲.不敢独享,所以现在把各种驱动以及安装教程分享出来. 注意: 打印机在开机状态下,电脑在开机状态下,不要插拔连接线!!! ...

  8. Linux入门(6)——Ubuntu16.04安装atom

    打开终端,依次输入: sudo add-apt-repository ppa:webupd8team/atom sudo apt-get update sudo apt-get install ato ...

  9. Redis主从环境配置

    1.Redis主从同步原理 redis主服务器会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,然后将数据文件同步给从服务器,从服务器加载记录文件,在内存库中更新新数据. 2.VMWar ...

  10. iOS之 重绘机制

    最近在看Core Animation , 今天来谈谈CALayer 和 UIView 中的重绘的一些认识: 我们都知道UIView里面有个成员layer,利用这个这个layer我们可以设置一些圆角,阴 ...