【问题标题】:Images not shown in JasperReports' html reportJasperReports 的 html 报告中未显示图像
【发布时间】:2012-01-04 23:02:31
【问题描述】:

我正在开发一个使用 JasperReport 和 Spring MVC 3 将生成的报告 (html) 显示到网页中的报告 Web 应用程序。

我是这两个框架的新手,在 html 报告中呈现图像时遇到问题。

Tomcat 日志:

No mapping found for HTTP request with URI [/<app-name>/<image-name>] in DispatcherServlet with name '<app-name>'

我猜可能由于DispatcherServlet 映射网址:<url-pattern>/</url-pattern>,报告中的图像未显示。

使用<mvc:resources /> 标签可能是解决方案?

编辑:

我在模型中添加了一些导出参数:

model.addAttribute("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR",
            Boolean.TRUE);
model.addAttribute("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_DIR_NAME",
            request.getSession().getServletContext()
                    .getRealPath("/WEB-INF/reports/images"));
model.addAttribute("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI",
            request.getContextPath() + "/WEB-INF/reports/images");

但问题仍然存在。

【问题讨论】:

标签: java spring web-applications spring-mvc jasper-reports


【解决方案1】:

我已经按照 ivanbron 在这篇文章中建议的解决方法解决了我的问题:

http://forum.springsource.org/showthread.php?42317-JasperReport-IN-HTML-using-Spring&p=149743#post149743

如果这是最好的方法,我现在不知道......但它有效!

【讨论】:

    猜你喜欢
    • 2015-08-14
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多