问题
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