接口返回json串

来源:互联网 发布:java读取xml配置文件 编辑:程序博客网 时间:2024/05/18 22:43
public String getSweepInfo(){String cropsProductionId = "";String productId = "";try {cropsProductionId = paymentService.findProductIdByTraceCode(traceCode);} catch (Exception e) {e.printStackTrace();}List<AttachReference> list= new ArrayList<AttachReference>();if(StringUtils.isNotBlank(cropsProductionId)){cropsProduction = cropsProductionService.get(cropsProductionId);productId = cropsProduction.getProductId();if(StringUtils.isNotBlank(productId)){basicProduct = basicProductService.get(productId);list = attachReferenceService.referenceAttachment(productId, "basicProduct.img");}}String [] infoarrays = new String  [3];infoarrays[0] = list.get(0).getAttachment().getPath();infoarrays[1] = cropsProduction.getName();infoarrays[2] = basicProduct.getGoodsDemo();String [] otherMessage = new String  [4];otherMessage[0] = cropsProduction.getId();otherMessage[1] = cropsProduction.getBatchNo();otherMessage[2]= traceCode;otherMessage[3] = isSign;Map<String, Object[]> map = new LinkedHashMap();map.put("info", infoarrays);map.put("otherMessage", otherMessage);try {            this.response.setContentType("application/json");            this.response.setCharacterEncoding("utf-8");            this.response.getWriter().print(new Gson().toJson(map));        } catch (IOException e) {            e.printStackTrace();        }return null;}

0 0
原创粉丝点击