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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM