JasperReports的html报告中未显示图像

时间:2021-02-02 21:05:39

I'm working on a reporting web application using JasperReport and Spring MVC 3 to show generated reports (html) into web pages.

我正在使用JasperReport和Spring MVC 3处理报告Web应用程序,以将生成的报告(html)显示到网页中。

I'm new to both frameworks and I'm having troubles rendering images in html reports.

我是两个框架的新手,我在html报告中渲染图像时遇到了麻烦。

Tomcat log:

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

在名为“ ”的DispatcherServlet中找不到具有URI [/ / ]的HTTP请求的映射

I guess that images in the report are not shown probably due to the DispatcherServlet mapping url: <url-pattern>/</url-pattern>.

我想报告中的图像可能不会显示,可能是由于DispatcherServlet映射url: / 。

Using the <mvc:resources /> tag could be the solution?

使用 标签可能是解决方案吗?

EDIT:

I've added some export parameters to the model:

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

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");

but the problem persists.

但问题仍然存在。

1 个解决方案

#1


0  

I've solved my problem following the workaround suggested by ivanbron in this post:

我根据ivanbron在这篇文章中提出的解决方法解决了我的问题:

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

I don't now if it's the best way... but it works!

如果这是最好的方式我现在不会...但是它有效!

#1


0  

I've solved my problem following the workaround suggested by ivanbron in this post:

我根据ivanbron在这篇文章中提出的解决方法解决了我的问题:

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

I don't now if it's the best way... but it works!

如果这是最好的方式我现在不会...但是它有效!