0
点赞
收藏
分享

微信扫一扫

下载json数据

猎书客er 2022-02-13 阅读 59
HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        headers.setContentDisposition(ContentDisposition.builder("attachment")
                .filename(templateExport.getTemplate().getName() + ".json", StandardCharsets.UTF_8).build());
        byte[] bytes;
        try {
            bytes = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(templateExport);
        } catch (JsonProcessingException e) {
            throw new BizException(CommonCode.InternalError, "数据错误", e);
        }
        return new ResponseEntity(new InputStreamResource(new ByteArrayInputStream(bytes)), headers, HttpStatus.OK);
举报

相关推荐

0 条评论