Images not shown in JasperReports' html report

允我心安 提交于 2019-12-24 21:12:03

问题


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.


回答1:


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

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!



来源:https://stackoverflow.com/questions/8245832/images-not-shown-in-jasperreports-html-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!