對象賦值空指針

for (Integer type : typelist) {
BigDecimal jprice = new BigDecimal(“0.00”);
for (Bxcommodity com : bxcomm) {
//查詢出來的數據賦值給對象,但是數據庫中沒有數據時賦值給對象後,會報空指針的錯誤!
Bxprice price= bxpriceManage.queryPriceBycommdityId(com.getComCode(),type);
if (price !=null) {加上判斷
jprice.add(new BigDecimal(price.getMprice()));
map.put(“name”,price.getTypename());
map.put(“total”, jprice);
}
}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章