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.
Update:
public class TimeSheetReportPdfView extends AbstractPdfView {
@SuppressWarnings("unchecked")
@Override
protected void buildPdfDocument(Map model, Document document,
PdfWriter writer, HttpServletRequest request, HttpServletResponse response)
throws Exception {
}
Any help appreciated.
Thanks.