“HTTP 状态 404 - 结果“null”;未找到”使用 JasperReport 的 Web 服务导出 XLS(可能与 Jasper 无关)
(这有可能与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论