当前位置:网站首页>Set object value changes null value object
Set object value changes null value object
2022-07-01 19:54:00 【Ink stained with frost】
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);
}
Print the results :
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]
From the print results , Collection null value new The value of , Cannot change the object
It needs to be replaced with the following code :
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);
}
Print the results :
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":[]}]
边栏推荐
- 墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
- Wechat applet realizes keyword highlighting
- Use of common built-in classes of JS
- 今日群里分享的面试题
- GC垃圾回收
- Linux下安装Redis,并配置环境
- Salesmartly has some tricks for Facebook chat!
- SQL 入门计划-1-选择
- #yyds干货盘点#SQL聚合查询方法总结
- HLS4ML报错The board_part definition was not found for tul.com.tw:pynq-z2:part0:1.0.
猜你喜欢
Optaplanner learning notes (I) case cloud balance
Basic use of MySQL
EasyCVR集群视频广场页面切换时,请求流未能终止的问题优化
Test self-study people must see: how to find test items in software testing?
Win11暂停更新点不了怎么办?Win11暂停更新是灰色的如何解决?
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
【多线程】锁策略
Uni app wechat applet one click login to obtain permission function
Redis installation and startup in Windows environment (background startup)
The key to the success of digital transformation enterprises is to create value with data
随机推荐
Example explanation: move graph explorer to jupyterlab
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
3D全景模型展示可视化技术演示
Sum the amount
Win11如何取消任务栏隐藏?Win11取消任务栏隐藏的方法
mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
振弦采集模块测量振弦传感器的流程步骤
SQL 入门计划-1-选择
Object creation
Redis installation and startup in Windows environment (background startup)
Detailed configuration of network security "Splunk" in national vocational college skills competition
[untitled]
list大集合等比分割成多个小list集合
[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached
GC垃圾回收
使用Zadig从0到1搭建持续交付平台
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road
Basic use of MySQL
Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
Mysql查询结果去除换行