前端返回$ref:$returnlist.data[0].line的数据问题

前端返回 r e f : ref: ref:returnlist.data[0].line的数据问题

前端返回 r e f : ref: ref:returnlist.data[0].line的数据问题

后端数据打印都是对的,前端显示却不知道是什么鬼东西,
在这里插入图片描述
上网查询了之后说是对象的重复引用的问题,
那什么是重复引用?
重复引用就是一个集合/对象中的多个元素/属性同时引用同一对象,循环引用就是集合/对象中的多个元素/属性存在相互引用导致循环。

解决
网上的方法是使用JSONObject.toJSONString(date,SerializerFeature.DisableCircularReferenceDetect);//date是结果,(通过禁止循环引用),但是我使用时说SerializerFeature is not define(不知道是不是用错了地方)
之前的代码

  list = logisticsLocalDao.logisticslocas(param)for(Map<String,Object> temp:list) {
             List lines = new ArrayList<>();
             lines = logisticsLocalDao.lines(temp);
             if(lines != null && lines.size()>0) {
              temp.put("lines", lines);             
             }else
              if(temp.get("line") != null && !temp.get("line").equals("")) {
               String line = temp.get("line").toString();
               String [] liness = line.split(",");              
               for(int i=0; i<liness.length;i++) {
                Map map = new HashMap<>();
                String str = liness[i];
                map.put("startpro", "");
                map.put("startplace", "");
                map.put("endpro", "");
                map.put("endplace", "");
                map.put("price", "0");
                map.put("pricevolume", "0");
                map.put("oid", "");
                map.put("logisticslocalid",temp.get("logisticslocalid"));
                map.put("startplacetow", str.substring(0,str.indexOf('到')));
                map.put("endplacetow", str.substring(str.indexOf('到')+1));
                lines.add(map);
               }
               temp.put("lines", lines);
              }else {
               temp.put("lines", "");
              }
             }
            

我觉得可能问题出现在lines的引用上,于是重新new了一个新的list,就可以了

List lines = new ArrayList<>();
             lines = logisticsLocalDao.lines(temp);
             if(lines != null && lines.size()>0) {
              temp.put("lines", lines);             
             }else {
              List lines1 = new ArrayList<>();
              if(temp.get("line") != null && !temp.get("line").equals("")) {
               String line = temp.get("line").toString();
               String [] liness = line.split(",");              
               for(int i=0; i<liness.length;i++) {
                Map map = new HashMap<>();
                String str = liness[i];
                map.put("startpro", "");
                map.put("startplace", "");
                map.put("endpro", "");
                map.put("endplace", "");
                map.put("price", "0");
                map.put("pricevolume", "0");
                map.put("oid", "");
                map.put("logisticslocalid",temp.get("logisticslocalid"));
                map.put("startplacetow", str.substring(0,str.indexOf('到')));
                map.put("endplacetow", str.substring(str.indexOf('到')+1));
                lines1.add(map);
               }
               temp.put("lines", lines1);
              }else {
               temp.put("lines", "");
              }
             }
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值