“HTTP 状态 404 - 结果“null”;未找到”使用 JasperReport 的 Web 服务导出 XLS(可能与 Jasper 无关)

发布于 2024-12-05 09:23:25 字数 1287 浏览 1 评论 0原文

(这有可能与 Jasper 无关,但它只发生在我的 Web 服务实现中,而不是普通的 JasperServer 接口)

我已经实现了 Web 服务,当我导出到 XLS 时,我看到非常奇怪的行为(没有XLSX、CSV、PDF 的问题)。当报告返回少量结果时,它将不会导出。相反,我的浏览器给出:“HTTP 状态 404 - 未找到结果‘null’”。当有大量结果时,它会正确导出。我一直无法找到给出任何提示的日志消息。

因此,我删除了除详细信息之外的所有报告区域,并且能够确定 43 或更多行将正确导出 XLS,但 42 或更少将导致错误。我通过排除法将查询从“select TOP 10 ...”更改为“select TOP 20 ...”再到“select TOP 30 ...”等来解决这个问题。43是一个奇怪的数字,所以我认为这可能与像素有关。我调整了详细信息带和整个报告上的像素数,但 42 行与 43 行的问题仍然存在。

此时我的报告显示了三个字段,因此我删除了其中两个字段,然后运行报告,问题又回来了。我没有费心去研究确切的行数,但现在神奇的数字在 60 到 80 行之间。

您可以在此处查看我的代码片段: http://pastebin.com/MyPYMju4

        JasperPrint print; = client.runReport(rd, reportInputMap);
        response.setHeader("Content-Disposition", " inline; filename=report" + (new Date()).getTime() + "." + format.toLowerCase());
        JRAbstractExporter myExporter;

        /// ... if/else code to determine what file to export to ...

        myExporter = new JRXlsExporter();
        response.setContentType(FORMAT_CONTENTTYPE_MAP.get(format));
        myExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
        myExporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
        myExporter.exportReport();

(There is a chance that this has nothing to do with Jasper, but it only happens with my web services implementation, NOT with the normal JasperServer interface)

I have implemented web services and when I export to XLS I am seeing very strange behavior (no problems with XLSX, CSV, PDF). When the report returns a small number results it will not export. Instead my browser gives: "HTTP Status 404 - result 'null' not found". When there are a large number of results it will export correctly. I have been unable to find a log messages that give any hints.

So I removed all report bands except for the details and was able to determine that 43 or more rows will export XLS correctly, but 42 or less will cause the error. I figured this out by process of elimination changing my query from "select TOP 10 ..." to "select TOP 20 ..." to "select TOP 30 ...", etc, etc etc. 43 is a strange number so I thought it might have to do with pixels. I played with the number of pixels on my details band and of the entire report, but the 42 vs 43 row problem persisted.

At this time my report was displaying three fields, so I removed two of them ran the report and the problem returned. I didn't bother honing in on the exact number of rows, but now the magic number was somewhere between 60 and 80 rows.

You can see a snippet of my code here: http://pastebin.com/MyPYMju4

        JasperPrint print; = client.runReport(rd, reportInputMap);
        response.setHeader("Content-Disposition", " inline; filename=report" + (new Date()).getTime() + "." + format.toLowerCase());
        JRAbstractExporter myExporter;

        /// ... if/else code to determine what file to export to ...

        myExporter = new JRXlsExporter();
        response.setContentType(FORMAT_CONTENTTYPE_MAP.get(format));
        myExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
        myExporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
        myExporter.exportReport();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文