JasperReports的html报告中未显示图像 [英] Images not shown in JasperReports' html report
问题描述
我正在使用JasperReport和Spring MVC 3处理报告Web应用程序,以便将生成的报告(html)显示到网页中。
我是两个新手框架和我在html报告中渲染图像时遇到了麻烦。
Tomcat日志:
在DispatcherServlet中找不到具有URI [/< app-name> /< image-name>]的HTTP请求的映射,其名称为< 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 /报告/图像));
model.addAttribute(net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI,
request.getContextPath()+/ WEB-INF / reports / images);
但问题仍然存在。
我已按照 ivanbron 在此帖中提出的解决方法解决了我的问题:
我现在不知道如果这是最好的方式......但它确实有效!
I'm working on a reporting web application using JasperReport and Spring MVC 3 to show generated reports (html) into web pages.
I'm new to both frameworks and I'm having troubles rendering images in html reports.
Tomcat log:
No mapping found for HTTP request with URI [/<app-name>/<image-name>] in DispatcherServlet with name '<app-name>'
I guess that images in the report are not shown probably due to the DispatcherServlet
mapping url: <url-pattern>/</url-pattern>
.
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.
I've solved my problem following the workaround suggested by ivanbron in this post:
I don't now if it's the best way... but it works!
这篇关于JasperReports的html报告中未显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!