Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "goods_name")

  记录一下这个错误。

报错原因:

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

分析:

由于项目框架里有个将map封装成PageData,我通过new PageData ,将前端jsp传到controller的参数进行保存。不过没有再做pd.put("goods_name",pd.getString("goods_name"));处理,而此时maping.xml里就不能在用pd获取了。(它会直接用它封装的方法,return 一个map)

错误写法:

<if test="pd.goods_name!= null and pd.goods_name!= ''">
            and
            goods_name like concat('%', #{pd.goods_name},'%')
</if>

把pd.去掉即可。

<if test="goods_name!= null and goods_name!= ''">
            and
            goods_name like concat('%', #{goods_name},'%')
</if>
原文地址:https://www.cnblogs.com/yuanmaolin/p/11150230.html