function daochu(data) { var time1 = $("#start").val(); var time2 = $("#end").val(); if (time1 == "") { time1 = new Date("2000-01-01 :00:00:00"); } else { time1 = new Date(time1); } if (time2 == "") { time2 = new Date(); } else { time2 = new Date(time2); } var area = $("#city").val(); var bId = $("#factory").val(); var str='/ProductiongetExcel/'+area+'/'+time1+'/'+time2+'/'+bId; var str="/ProductiongetExcel1?area="+area+"&time1="+time1+"&time2="+time2+"&bId="+bId; $("#aa").attr("href",str); } 这里看到两个str,都是要往后台传递的url,第一种方式可以把time直接以date类型传递到后台, 第二种方式,传递到后台time是String类型,以后注意。 下面贴出第一种方式后台接受这个url的接口@RequestMapping("/ProductiongetExcel/{area}/{time1}/{time2}/{breedId}") @ResponseBody public void productionExportDownload( @PathVariable(value = "area") String area, @PathVariable(value = "time1") Date time1, @PathVariable(value = "time2") Date time2, @PathVariable(value = "breedId") String breedId, HttpServletResponse response, HttpServletRequest request ) throws IOException { Long bId=Long.parseLong(breedId); Map criteria = new HashMap(); List<Long> breedFactoryIds = new ArrayList<>(); if ("全部".equals(area) && bId == -1L) { Map mapuser = getarea(response, request); List<BreedFactory> breedFactoryList = (List<BreedFactory>) mapuser.get("breedFactorys"); for (BreedFactory breedFactory : breedFactoryList) { breedFactoryIds.add(breedFactory.getId()); } } else if (bId != -1L) { breedFactoryIds.add(bId); }else { List list1 = new ArrayList(); list1.add(area); Map areas = new HashMap(); areas.put("areas", list1); List<BreedFactory> breedFactoryList = (List<BreedFactory>) breedFactoryReadService.findByArea(areas).getResult(); for (BreedFactory breedFactory : breedFactoryList) { breedFactoryIds.add(breedFactory.getId()); } } criteria.put("breedFactoryIds", breedFactoryIds); criteria.put("deleteFlag", 1); criteria.put("time1", time1); criteria.put("time2", time2); Response<Paging<ProductionReport>> pagingResponse = productionReportReadService.pagingbytimes(1, 600000, criteria); List<ProductionReport> productionReportList = pagingResponse.getResult().getData(); List<List> listList = new ArrayList<>(); for (ProductionReport productionReport : productionReportList) { List list = new ArrayList(); list.add(productionReport.getBreedFactoryName()); list.add(productionReport.getArea()); list.add(productionReport.getStableNumber()); list.add(productionReport.getBreedType()); list.add(productionReport.getUnit()); list.add(productionReport.getChangeQuantity()); list.add(productionReport.getBirthQuantity()); list.add(productionReport.getInQuantity()); list.add(productionReport.getOutQuantity()); list.add(productionReport.getDeathQuantity()); list.add(productionReport.getDate()); listList.add(list); } ExportOrImportUtils.UntilDownload(response, prodRecordInfoTitles(), listList, "生产记录"); }
超链接向后台传值含有日期
最新推荐文章于 2021-06-09 20:11:38 发布