解决控制器中,一对多断点不进array的原因

原因是:因为一对多之间的关系互相关联,之间有重复的属性,直接传数据就会出现不进断点的情况,这时需要

1.使用JsonConfig解决
      

        /*
         * 获取商品分类
         */
        @RequestMapping("getAllBigType")
        public String getAllBigType(HttpServletResponse response){
            JsonConfig jsonConfig = new JsonConfig();
            //获取商品大的分类
            List<BigType> bigTypes = bigTypeService.getAllBigType();
            jsonConfig.setExcludes(new String[]{"bigType"});
            JSONArray jsonArray = JSONArray.fromObject(bigTypes,jsonConfig);
            OutUtil.print(jsonArray, response);
            return null;
        }

jsonConfig.setExcludes(new String[]{"bigType"});过滤掉不需要的属性,这样就可以将数据装进json了,断点也能执行了。

猜你喜欢

转载自blog.csdn.net/qq_38337245/article/details/81410018