ResponseEntity
文件下载 同时响应状态码 , 失败或者其它,响应 对应的message
@GetMapping("/manifestReport") public ResponseEntity getManifestReportByBagIds(@RequestParam List<String> bagIds, HttpServletRequest request, HttpServletResponse response) throws Exception{ JSONObject result = lazadaManifestReportHandler.getManifestReportByBagIds(bagIds); if((ResponseCode.SUCCESS.getCode()+"").equalsIgnoreCase(result.getString(ResponseUtil.RESPONSE_CODE))){ XSSFWorkbook workbook = (XSSFWorkbook)result.get(ResponseUtil.RESPONSE_DATA); OutputStream output=response.getOutputStream(); response.reset(); String fileName="Sea_Report" + DateUtils.formatDate(new Date(),DateUtils.STANDARD_NO_BLANK); response.setHeader("Content-disposition", "attachment; filename="+fileName+".xlsx"); response.setContentType("application/msexcel"); workbook.write(output); return ResponseEntity.status(200).body(""); }else { return ResponseEntity.status(Integer.valueOf(result.getString(ResponseUtil.RESPONSE_CODE))).body(result); } }
标签:文件,ResponseUtil,RESPONSE,响应,result,ResponseEntity,response,下载 From: https://www.cnblogs.com/lshan/p/17265001.html