当前位置:网站首页>集合对象值改变NULL值对象
集合对象值改变NULL值对象
2022-07-01 18:45:00 【墨着染霜华】
List<ShangpinInfoVODTO> footers= baseShangpinMapper.selectShangpinPageFooterList(term,wrapper);
fillFootersKcJeByKhJgsd( khdm,footers);
log("footers",footers,true);
protected void fillFootersKcJeByKhJgsd(String khdm,List<ShangpinInfoVODTO> footers) throws Exception{
String jgsd=baseKehuService.getJgsd2VOByKhdm(khdm).getJgsd();
fillFootersKcJeByJgsd( jgsd,footers);
}
protected void fillFootersKcJeByJgsd(String jgsd,List<ShangpinInfoVODTO> footers) throws Exception{
for(ShangpinInfoVODTO vo:footers){
log("vo1", vo, true);
if(null==vo) {
vo=new ShangpinInfoVODTO();
vo.setKcsl(0);
vo.setKcje(0.0);
}else{
switch(jgsd){
case "BZSJ":vo.setKcje(vo.getBzsje()); break;
case "SJ1": vo.setKcje(vo.getSj1e()); break;
case "SJ2": vo.setKcje(vo.getSj2e()); break;
case "SJ3": vo.setKcje(vo.getSj3e()); break;
case "SJ4": vo.setKcje(vo.getSj4e()); break;
case "4":vo.setKcje(vo.getBzsje()); break;
case "5": vo.setKcje(vo.getSj1e()); break;
case "6": vo.setKcje(vo.getSj2e()); break;
case "7": vo.setKcje(vo.getSj3e()); break;
case "8": vo.setKcje(vo.getSj4e()); break;
default:break;
}
}
if(null==vo.getKcsl()) vo.setKcsl(0);
if(null==vo.getKcje()) vo.setKcje(0.0);
log("vo2", vo, true);
}
log("footers1", footers, true);
}打印结果:
2022-06-30 10:08:39.419 INFO 1376 --- [io-18089-exec-2] com.hieasy.comm.util.BaseUtil : vo1:null
2022-06-30 10:08:39.419 INFO 1376 --- [io-18089-exec-2] com.hieasy.comm.util.BaseUtil : vo2:{"guige1List":[],"kcje":0.0,"kcsl":0,"limitKcys":0,"limitKcysType":0,"picList":[]}
2022-06-30 10:08:39.419 INFO 1376 --- [io-18089-exec-2] com.hieasy.comm.util.BaseUtil : footers1:[null]
2022-06-30 10:08:39.430 INFO 1376 --- [io-18089-exec-2] com.hieasy.comm.util.BaseUtil : footers:[null]
从打印结果来看,集合中null值 new 出来的值 ,并不能改变对象
需要更替为以下代码:
protected void fillFootersKcJeByKhJgsd(String khdm,List<ShangpinInfoVODTO> footers) throws Exception{
String jgsd=baseKehuService.getJgsd2VOByKhdm(khdm).getJgsd();
fillFootersKcJeByJgsd( jgsd,footers);
}
protected void fillFootersKcJeByJgsd(String jgsd,List<ShangpinInfoVODTO> footers) throws Exception{
for (int i = 0; i < footers.size(); i++) {
ShangpinInfoVODTO sp= footers.get(i);
if(null==sp) {
sp=new ShangpinInfoVODTO();
sp.setKcsl(0);
sp.setKcje(0.0);
footers.set(i, sp);
}else{
switch(jgsd){
case "BZSJ":sp.setKcje(sp.getBzsje()); break;
case "SJ1": sp.setKcje(sp.getSj1e()); break;
case "SJ2": sp.setKcje(sp.getSj2e()); break;
case "SJ3": sp.setKcje(sp.getSj3e()); break;
case "SJ4": sp.setKcje(sp.getSj4e()); break;
case "4":sp.setKcje(sp.getBzsje()); break;
case "5": sp.setKcje(sp.getSj1e()); break;
case "6": sp.setKcje(sp.getSj2e()); break;
case "7": sp.setKcje(sp.getSj3e()); break;
case "8": sp.setKcje(sp.getSj4e()); break;
default:break;
}
}
}
log("footers1", footers, true);
}打印结果:
2022-06-30 10:19:36.651 INFO 8584 --- [io-18089-exec-2] com.hieasy.comm.util.BaseUtil : footers1:[{"guige1List":[],"kcje":0.0,"kcsl":0,"limitKcys":0,"limitKcysType":0,"picList":[]}]
边栏推荐
- Ubuntu14 install MySQL and configure root account local and remote access
- How to redraw the header of CListCtrl in MFC
- Regular expression =regex=regular expression
- Nat penetration of gb28181
- Introduction and installation of crunch, and making password dictionary with crunch
- DDR4 test-2
- Dom4j parsing XML, XPath retrieving XML
- ddr4测试-2
- DTD modeling
- Werewolf killing strategy: do you think I'm easy to cheat? Who do we believe!
猜你喜欢

Uni app product classification

Optimization of video streaming with repeated requests in the case of unstable easygbs network

Solidity - contract structure - error - ^0.8.4 NEW

微信公众号开发相关流程及功能介绍

uni-app微信小程序一键登录获取权限功能

正则表达式=Regex=regular expression
![Thesis reading [distinctive late semantic graph for video capturing]](/img/d4/4f84a73a9127fa87bb0a74c4655d15.png)
Thesis reading [distinctive late semantic graph for video capturing]

Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation

DDR4 test-2

Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
随机推荐
【To .NET】C#集合类源码解析
Brpc understanding
使用环信提供的uni-app Demo,快速实现一对一单聊
Thesis reading [distinctive late semantic graph for video capturing]
Opencv video quality diagnosis - VIDEO occlusion diagnosis
科技T3国产平台!成功搭载“翼辉国产实时系统SylixOS”
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
uni-app微信小程序一键登录获取权限功能
How to correctly use vertx to operate redis (3.9.4 with source code analysis)
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Why must we move from Devops to bizdevops?
English grammar_ Adjective / adverb Level 3 - precautions
Interview question 16.16 Partial sorting - Double finger needling
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
XML syntax, constraints
Summary of SQL query de duplication statistics methods
torch. nn. functional. Interpolate function
axure不显示元件库
Optaplanner learning notes (I) case cloud balance
Crunch简介、安装,使用Crunch制作密码字典