view is not rendered when returning ModelAndView
Posted
by adancu
on Stack Overflow
See other posts from Stack Overflow
or by adancu
Published on 2010-04-02T09:17:35Z
Indexed on
2010/04/02
9:23 UTC
Read the original article
Hit count: 259
Hi,
I have the following problem. I need to export a PDF in a controller
The code below, where I return a View, works as expected.
@RequestMapping(method = RequestMethod.GET)
public View exportReport(
@RequestParam(value = "userName", required = true) String userName,
@RequestParam(value = "startDate", required = true) Date startDate,
@RequestParam(value = "endDate", required = true) Date endDate) {
///////////////////////////////////////////
return new TimeSheetReportPdfView();
}
The problem occurs if I change the method to return a ModelAndView:
@RequestMapping(method = RequestMethod.GET)
public ModelAndView exportReport(
@RequestParam(value = "userName", required = true) String userName,
@RequestParam(value = "startDate", required = true) Date startDate,
@RequestParam(value = "endDate", required = true) Date endDate) {
///////////////////////////////////////////
return new ModelAndView(new TimeSheetReportPdfView(), model);
}
Now, the PDF is not exported, all I get is a blank page and nothing in the logs.
Any help appreciated.
Thanks.
© Stack Overflow or respective owner