我需要将一个对象传递给我的jasper报告页面。当我发送列表时它可以正常工作,但是当我发送一个像下面的代码这样的对象时,它不起作用。 我怎么能这样做?
报告制作方法代码:
// generatePdfReport
@RequestMapping(method = RequestMethod.GET, value = "/report/{id}")
public ModelAndView generatePdfReport(@PathVariable(value = "id") Long id, ModelAndView modelAndView)
throws JRException {
LOG.info("--------------generate PDF report----------");
Map<String, Object> parameterMap = new HashMap<String, Object>();
java.util.List<Node> nodeList = new ArrayList<Node>();
JRDataSource JRdataSource = new JRBeanCollectionDataSource(nodeList);
Node node = nodeService.getOne(id);
nodeList.add(node);
parameterMap.put("datasource", JRdataSource);
// pdfReport bean has ben declared in the spring configuration
modelAndView = new ModelAndView("pdfReport", parameterMap);
return modelAndView;
}
答案 0 :(得分:0)
我已经用以下代码解决了我的问题,感谢所有人:
// generatePdfReport single node
@RequestMapping(method = RequestMethod.GET, value = "/report/{id}")
public ModelAndView generatePdfReport(@PathVariable(value = "id") Long id, ModelAndView modelAndView)
throws JRException {
LOG.info("--------------generate PDF report----------");
Map<String, Object> parameterMap = new HashMap<String, Object>();
java.util.List<Node> nodeList = new ArrayList<Node>();
nodeList.add(nodeService.getOne(id));
JRDataSource JRdataSource = new JRBeanCollectionDataSource(nodeList);
parameterMap.put("datasource", JRdataSource);
// pdfReport bean has ben declared in the spring configuration
modelAndView = new ModelAndView("nodesReport_PDF", parameterMap);
return modelAndView;
}
答案 1 :(得分:-1)
在我的工作代码下面,希望会有所帮助。
1244, Daniel, 200000
1344, John, 59999
8742, Smith, 98009